cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/webapp/mount/slide rdf2html.xsl sitemap.xmap
Date Thu, 27 Jun 2002 16:53:38 GMT
stephan     2002/06/27 09:53:38

  Modified:    src/scratchpad/src/org/apache/cocoon/components/source/impl
                        SlideSource.java
               src/scratchpad/src/org/apache/cocoon/generation
                        SourceDescriptionGenerator.java
               src/scratchpad/webapp/mount/slide rdf2html.xsl sitemap.xmap
  Added:       src/scratchpad/src/org/apache/cocoon/acting
                        SourceAddPropertyAction.java
                        SourceDeleteContentAction.java
                        SourceDeletePropertyAction.java
                        SourceUploadAction.java
  Log:
  Create actions to upload files and modify their properties.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceAddPropertyAction.java
  
  Index: SourceAddPropertyAction.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.acting;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.acting.AbstractAction;
  import org.apache.cocoon.components.source.InspectableSource;
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.SourceResolver;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import java.util.Map;
  
  /**
   * This action add a property to a source
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: SourceAddPropertyAction.java,v 1.1 2002/06/27 16:53:37 stephan Exp $
   */
  public class SourceAddPropertyAction extends AbstractAction {
  
      /**
       * Controls the processing against some values of the
       * <code>Dictionary</code> objectModel and returns a
       * <code>Map</code> object with values used in subsequent
       * sitemap substitution patterns.
       *
       * @param resolver    The <code>SourceResolver</code> in charge
       * @param objectModel The <code>Map</code> with object of the
       *                    calling environment which can be used
       *                    to select values this controller may need
       *                    (ie Request, Response).
       * @param source      A source <code>String</code> to the Action
       * @param parameters  The <code>Parameters</code> for this invocation
       * @return Map        The returned <code>Map</code> object with
       *                    sitemap substitution values which can be used
       *                    in subsequent elements attributes like src=
       *                    using a xpath like expression: src="mydir/{myval}/foo"
       *                    If the return value is null the processing inside
       *                    the <map:act> element of the sitemap will
       *                    be skipped.
       * @exception Exception Indicates something is totally wrong
       */
      public Map act(Redirector redirector,
                     SourceResolver resolver,
                     Map objectModel,
                     String src,
                     Parameters parameters) throws Exception {
  
          Request request = ObjectModelHelper.getRequest(objectModel);
                  
          String uri = parameters.getParameter("uri", request.getParameter("uri"));
          String namespace = parameters.getParameter("namespace", 
              request.getParameter("namespace"));
          String name = parameters.getParameter("name", 
              request.getParameter("name"));
          String value = parameters.getParameter("value", 
              request.getParameter("value"));
  
          try {
  
              Source source = resolver.resolveURI(uri);
  
              if (source instanceof InspectableSource) {
                  InspectableSource inspectablesource = (InspectableSource)source;
  
                  SourceProperty property = new SourceProperty(namespace, name, value);
  
                  inspectablesource.setSourceProperty(property);
              } else
                  throw new ProcessingException("Source isn't inspectable");
          } catch (SourceException se) {
              throw new ProcessingException("Exception occurs while modifying the source", se);
          }
  
          return null;
      }
  }
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceDeleteContentAction.java
  
  Index: SourceDeleteContentAction.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.acting;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.acting.AbstractAction;
  import org.apache.cocoon.components.source.WriteableSource;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.SourceResolver;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import java.util.Map;
  
  /**
   * This action deletes a source from repository
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: SourceDeleteContentAction.java,v 1.1 2002/06/27 16:53:37 stephan Exp $
   */
  public class SourceDeleteContentAction extends AbstractAction {
  
      /**
       * Controls the processing against some values of the
       * <code>Dictionary</code> objectModel and returns a
       * <code>Map</code> object with values used in subsequent
       * sitemap substitution patterns.
       *
       * @param resolver    The <code>SourceResolver</code> in charge
       * @param objectModel The <code>Map</code> with object of the
       *                    calling environment which can be used
       *                    to select values this controller may need
       *                    (ie Request, Response).
       * @param source      A source <code>String</code> to the Action
       * @param parameters  The <code>Parameters</code> for this invocation
       * @return Map        The returned <code>Map</code> object with
       *                    sitemap substitution values which can be used
       *                    in subsequent elements attributes like src=
       *                    using a xpath like expression: src="mydir/{myval}/foo"
       *                    If the return value is null the processing inside
       *                    the <map:act> element of the sitemap will
       *                    be skipped.
       * @exception Exception Indicates something is totally wrong
       */
      public Map act(Redirector redirector,
                     SourceResolver resolver,
                     Map objectModel,
                     String src,
                     Parameters parameters) throws Exception {
  
          Request request = ObjectModelHelper.getRequest(objectModel);
  
          String uri = parameters.getParameter("uri", request.getParameter("uri"));
          String filename = parameters.getParameter("filename", request.getParameter("filename"));
  
          try {
              Source source = resolver.resolveURI(uri+"/"+filename);
  
              if (source instanceof WriteableSource) {
                  WriteableSource writeablesource = (WriteableSource)source;
  
                  //FIXME : evaluate a interface for a delete method
                  //writeablesource.delete();
  
              } else
                  throw new ProcessingException("Source isn't writeable");
  
          } catch (SourceException se) {
              throw new ProcessingException("Exception occurs while modifying the source", se);
          }
  
          return null;
      }
  }
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceDeletePropertyAction.java
  
  Index: SourceDeletePropertyAction.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.acting;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.acting.AbstractAction;
  import org.apache.cocoon.components.source.InspectableSource;
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.SourceResolver;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import java.util.Map;
  
  /**
   * Thie action deletes a property from a source
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: SourceDeletePropertyAction.java,v 1.1 2002/06/27 16:53:37 stephan Exp $
   */
  public class SourceDeletePropertyAction extends AbstractAction {
  
      /**
       * Controls the processing against some values of the
       * <code>Dictionary</code> objectModel and returns a
       * <code>Map</code> object with values used in subsequent
       * sitemap substitution patterns.
       *
       * @param resolver    The <code>SourceResolver</code> in charge
       * @param objectModel The <code>Map</code> with object of the
       *                    calling environment which can be used
       *                    to select values this controller may need
       *                    (ie Request, Response).
       * @param source      A source <code>String</code> to the Action
       * @param parameters  The <code>Parameters</code> for this invocation
       * @return Map        The returned <code>Map</code> object with
       *                    sitemap substitution values which can be used
       *                    in subsequent elements attributes like src=
       *                    using a xpath like expression: src="mydir/{myval}/foo"
       *                    If the return value is null the processing inside
       *                    the <map:act> element of the sitemap will
       *                    be skipped.
       * @exception Exception Indicates something is totally wrong
       */
      public Map act(Redirector redirector,
                     SourceResolver resolver,
                     Map objectModel,
                     String src,
                     Parameters parameters) throws Exception {
  
          Request request = ObjectModelHelper.getRequest(objectModel);
  
          String uri = parameters.getParameter("uri", request.getParameter("uri"));
          String namespace = parameters.getParameter("namespace",
              request.getParameter("namespace"));
          String name = parameters.getParameter("name",
              request.getParameter("name"));
  
          try {
  
              Source source = resolver.resolveURI(uri);
  
              if (source instanceof InspectableSource) {
                  InspectableSource inspectablesource = (InspectableSource)source;
  
                  inspectablesource.removeSourceProperty(namespace, name);
              } else
                  throw new ProcessingException("Source isn't inspectable");
          } catch (SourceException se) {
              throw new ProcessingException("Exception occurs while modifying the source", se);
          }
  
  
          return null;
      }
  }
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceUploadAction.java
  
  Index: SourceUploadAction.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.acting;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.acting.AbstractAction;
  import org.apache.cocoon.components.request.multipart.FilePartFile;
  import org.apache.cocoon.components.source.WriteableSource;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.SourceResolver;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.util.Map;
  
  /**
   * This action stores a new file via upload into a repository
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: SourceUploadAction.java,v 1.1 2002/06/27 16:53:37 stephan Exp $
   */
  public class SourceUploadAction extends AbstractAction implements Contextualizable {
  
      File uploadDir = null;
  
      /** Contextualize this class */
      public void contextualize(Context context) throws ContextException {
          uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
      }
  
      /**
       * Controls the processing against some values of the
       * <code>Dictionary</code> objectModel and returns a
       * <code>Map</code> object with values used in subsequent
       * sitemap substitution patterns.
       *
       * @param resolver    The <code>SourceResolver</code> in charge
       * @param objectModel The <code>Map</code> with object of the
       *                    calling environment which can be used
       *                    to select values this controller may need
       *                    (ie Request, Response).
       * @param source      A source <code>String</code> to the Action
       * @param parameters  The <code>Parameters</code> for this invocation
       * @return Map        The returned <code>Map</code> object with
       *                    sitemap substitution values which can be used
       *                    in subsequent elements attributes like src=
       *                    using a xpath like expression: src="mydir/{myval}/foo"
       *                    If the return value is null the processing inside
       *                    the <map:act> element of the sitemap will
       *                    be skipped.
       * @exception Exception Indicates something is totally wrong
       */
      public Map act(Redirector redirector,
                     SourceResolver resolver,
                     Map objectModel,
                     String src,
                     Parameters parameters) throws Exception {
  
          Request request = ObjectModelHelper.getRequest(objectModel);
  
          String uri = parameters.getParameter("uri", request.getParameter("uri"));
          String filename = parameters.getParameter("filename", request.getParameter("filename"));
  
          if ((request.get("file")!=null) && 
              (request.get("file") instanceof FilePartFile)) {
              File uploadFile = ((FilePartFile)request.get("file")).getFile();
  
              try {
                  Source source = resolver.resolveURI(uri+"/"+filename);
  
                  if (source instanceof WriteableSource) {
                      WriteableSource writeablesource = (WriteableSource)source;
  
                      OutputStream out = writeablesource.getOutputStream();
  
                      byte[] buffer = new byte[8192];
                      int length = -1;
  
                      InputStream in = new FileInputStream(uploadFile);
                      while ((length = in.read(buffer)) > -1) {
                          out.write(buffer, 0, length);
                      }
                      in.close();
                      out.flush();
                      out.close();
                  } else
                      throw new ProcessingException("Source isn't writeable");
  
              } catch (SourceException se) {
                  throw new ProcessingException("Exception occurs while storing the content", se);
              } catch (IOException ioe) {
                  throw new ProcessingException("Exception occurs while storing the content", ioe);
              }
          }
  
          /*System.out.println("file="+uploadFile);
  
          String[] filelist = uploadDir.list();
          for (int i = 0; i < filelist.length; i++)
              System.out.println("File [" + i + "]=" + filelist[i]);*/
  
          return null;
      }
  }
  
  
  
  
  1.5       +72 -4     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java
  
  Index: SlideSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SlideSource.java	26 Jun 2002 15:08:16 -0000	1.4
  +++ SlideSource.java	27 Jun 2002 16:53:37 -0000	1.5
  @@ -108,8 +108,9 @@
   import org.apache.slide.security.NodePermission;
   import org.apache.slide.security.Security;
   import org.apache.slide.structure.ObjectNode;
  -//import org.apache.slide.structure.ObjectNotFoundException;
  +import org.apache.slide.structure.ObjectNotFoundException;
   import org.apache.slide.structure.Structure;
  +import org.apache.slide.structure.SubjectNode;
   
   import java.io.ByteArrayOutputStream;
   import java.io.InputStream;
  @@ -251,7 +252,8 @@
               this.revisionDescriptor = null;
               this.sourcerevision = null;
               this.sourcerevisionbranch = null;
  -
  +        } catch (ObjectNotFoundException onfe) {
  +            getLogger().warn("Source doesn't exist", onfe);
           } catch (SlideException se) {
               throw new SourceException("Could not retrieve revision descriptor", se);
           }
  @@ -381,11 +383,12 @@
           public void close() throws IOException {
               super.close();
   
  +            byte[] bytes = new byte[0]; // must be initialized
               try {
                   NodeRevisionContent revisionContent =
                       new NodeRevisionContent();
   
  -                byte[] bytes = toByteArray();
  +                bytes = toByteArray();
                   revisionContent.setContent(bytes);
   
                   if (revisionDescriptor==null) {
  @@ -412,7 +415,67 @@
   
                   //nat.commit();
   
  +            } catch (ObjectNotFoundException e) {
  +                
  +                // Todo : Check to see if parent exists
  +                SubjectNode subject = new SubjectNode();
  +
  +                try {
  +                    // Creating an object 
  +                    structure.create(slideToken, subject, uri);
  +                } catch (SlideException se) {
  +                    // FIXME correct exception handling
  +                    e.printStackTrace();
  +                    throw new IOException(se.getMessage());
  +                }
  +
  +                NodeRevisionDescriptor revisionDescriptor =
  +                    new NodeRevisionDescriptor(bytes.length);
  +
  +                //NodeProperty property = null;
  +
  +                // Creation date
  +
  +                // Resource type
  +               // revisionDescriptor.setResourceType(""); //FIXME works only with CVS code of Slide
  +
  +                // Source
  +                //revisionDescriptor.setSource("");
  +
  +                // Get content language
  +                revisionDescriptor.setContentLanguage("en");
  +
  +                // Get content length
  +                revisionDescriptor.setContentLength(bytes.length);
  +
  +                // Get content type
  +                // FIXME retrieving the correct mime type
  +                revisionDescriptor.setContentType("application/octet-stream");
  +
  +                // Last modification date
  +                revisionDescriptor.setLastModified(new Date());
  +
  +                // Owner
  +                //revisionDescriptor.setOwner(
  +                //    slideToken.getCredentialsToken().getPublicCredentials());
  +
  +                // Creating revisionDescriptor associated with the object
  +                NodeRevisionContent revisionContent =
  +                    new NodeRevisionContent();
  +                revisionContent.setContent(bytes);
  +
  +                try {
  +                    content.create(slideToken, uri, revisionDescriptor,
  +                                   revisionContent);
  +                } catch (SlideException se) {
  +                    // FIXME correct exception handling
  +                    e.printStackTrace();
  +                    throw new IOException(se.getMessage());
  +                }
  +
               } catch (Exception e) {
  +                // FIXME correct exception handling
  +                e.printStackTrace();
                   throw new IOException(e.getMessage());
               } finally {
                   this.isClosed = true;
  @@ -439,6 +502,9 @@
        */
       public long getContentLength()
       {
  +        if (revisionDescriptor!=null)
  +            return revisionDescriptor.getContentLength();
  +
           return -1;
       }
   
  @@ -448,6 +514,8 @@
        */
       public long getLastModified()
       {
  +        if (revisionDescriptor!=null)
  +            return revisionDescriptor.getLastModifiedAsDate().getTime();
           return 0;
       }
   
  
  
  
  1.4       +6 -3      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java
  
  Index: SourceDescriptionGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SourceDescriptionGenerator.java	26 Jun 2002 15:08:16 -0000	1.3
  +++ SourceDescriptionGenerator.java	27 Jun 2002 16:53:38 -0000	1.4
  @@ -77,6 +77,7 @@
   import org.apache.cocoon.components.source.helpers.SourceProperty;
   //import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.cocoon.xml.EmbeddedXMLPipe;
   
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
  @@ -316,7 +317,7 @@
           for (int i=0; i<properties.length; i++) {
               property = properties[i];
   
  -            this.contentHandler.startPrefixMapping("prop", property.getNamespace());
  +            /*this.contentHandler.startPrefixMapping("prop", property.getNamespace());
   
               this.contentHandler.startElement(property.getNamespace(), property.getName(), 
                                                property.getName(), new AttributesImpl());
  @@ -325,7 +326,9 @@
               this.contentHandler.endElement(property.getNamespace(), property.getName(), 
                                              property.getName());
   
  -            this.contentHandler.endPrefixMapping("prop");
  +            this.contentHandler.endPrefixMapping("prop");*/
  +
  +            property.toSAX(new EmbeddedXMLPipe(this.contentHandler));
           }
       }
   
  
  
  
  1.3       +19 -54    xml-cocoon2/src/scratchpad/webapp/mount/slide/rdf2html.xsl
  
  Index: rdf2html.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/slide/rdf2html.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- rdf2html.xsl	26 Jun 2002 15:08:16 -0000	1.2
  +++ rdf2html.xsl	27 Jun 2002 16:53:38 -0000	1.3
  @@ -7,12 +7,6 @@
   
    <xsl:output indent="yes"/>
   
  - <xsl:param name="namespace">myrepository</xsl:param>
  - <xsl:param name="cocoon-action-addproperty"></xsl:param>
  - <xsl:param name="propertynamespace">bla1</xsl:param>
  - <xsl:param name="propertyname">bla2</xsl:param>
  - <xsl:param name="propertyvalue">bla3</xsl:param>
  -
    <xsl:template match="/">
     <html>
      <head>
  @@ -25,20 +19,6 @@
    </xsl:template>
   
    <xsl:template match="rdf:Description">
  -<!--
  -  "cocoon-action-addproperty=<xsl:value-of select="$cocoon-action-addproperty"/>"
  -  "propertynamespace=<xsl:value-of select="$propertynamespace"/>"
  -  "propertyname=<xsl:value-of select="$propertynamespace"/>"
  -  "propertyvalue=<xsl:value-of select="$propertyvalue"/>"
  --->
  -<!--  <xsl:choose>
  -   <xsl:when test="$cocoon-action-addproperty!=''">
  -    <slide:slide namespace="{$namespace}" uri="{source:uri}">
  -     <slide:setproperty namespace="{$propertynamespace}" name="{$propertyname}"><xsl:value-of 
  -              select="$propertyvalue"/></slide:setproperty>
  -    </slide:slide>
  -   </xsl:when>
  -  </xsl:choose>-->
   
     <table width="90%" cellspacing="0" cellpadding="5" align="center">
      <tr>
  @@ -50,11 +30,11 @@
       </td>
      </tr>
      <tr>
  -    <td colspan="3" bgcolor="#eeeeee"><a href="/cocoon/mount/slide/browse/{$namespace}/">Home</a></td>
  +    <td colspan="3" bgcolor="#eeeeee"><a href="/cocoon/mount/slide/browse/">Home</a></td>
       <td colspan="2" bgcolor="#eeeeee">
        <xsl:if test="dav:getcontentlength!='' and dav:getcontentlength!='0'">
         <xsl:if test="dav:resourcetype!='&lt;collection/>'">
  -       <a href="/cocoon/mount/slide/view/{$namespace}{source:uri}">Download</a>
  +       <a href="/cocoon/mount/slide/view/{@rdf:about}">Download</a>
         </xsl:if>
        </xsl:if>
       </td>
  @@ -108,32 +88,30 @@
           <td align="left"><tt><xsl:value-of select="local-name(.)"/></tt></td>
           <td align="left"><tt><xsl:value-of select="."/></tt></td>
           <td align="right">
  -         <xsl:if test="@namespace!='DAV:'">
  +         <!--<xsl:if test="@namespace!='DAV:'">-->
             <form action="" method="get">
  -           <input type="hidden" name="namespace" value="{$namespace}"/>
  -           <input type="hidden" name="uri" value="{../../../../source:uri}"/>
  -           <input type="hidden" name="propertynamespace" value="{@namespace}"/>
  -           <input type="hidden" name="propertyname" value="{@name}"/>
  +           <input type="hidden" name="uri" value="{../@rdf:about}"/>
  +           <input type="hidden" name="namespace" value="{namespace-uri()}"/>
  +           <input type="hidden" name="name" value="{local-name()}"/>
    
              <input type="submit" name="cocoon-action-deleteproperty" value="Delete"/>
             </form>
  -         </xsl:if>
  +         <!--</xsl:if>-->
           </td>
          </tr>
         </xsl:for-each>
   
         <tr bgcolor="#eeeeee">
          <form action="" method="get">
  -        <input type="hidden" name="namespace" value="{$namespace}"/>
  -        <input type="hidden" name="uri" value="{source:uri}"/>
  +        <input type="hidden" name="uri" value="{@rdf:about}"/>
           <td align="left">
  -         <input name="propertynamespace" type="text" size="25" maxlength="40"/>
  +         <input name="namespace" type="text" size="25" maxlength="40"/>
           </td>
           <td align="left">
  -         <input name="propertyname" type="text" size="25" maxlength="40"/>
  +         <input name="name" type="text" size="25" maxlength="40"/>
           </td>
           <td align="left">
  -         <input name="propertyvalue" type="text" size="25" maxlength="40"/>
  +         <input name="value" type="text" size="25" maxlength="40"/>
           </td>
           <td align="right">
            <input type="submit" name="cocoon-action-addproperty" value="Add/Modify"/>
  @@ -165,8 +143,7 @@
   
         <tr bgcolor="#eeeeee">
          <form action="" method="post">
  -        <input type="hidden" name="namespace" value="{$namespace}"/>
  -        <input type="hidden" name="uri" value="{source:uri}"/>
  +        <input type="hidden" name="uri" value="{@rdf:about}"/>
           <td align="left">
            <input name="permissonsubject" type="text" size="25" maxlength="40"/>
           </td>
  @@ -217,8 +194,7 @@
   
         <tr bgcolor="#eeeeee">
          <form action="" method="post">
  -        <input type="hidden" name="namespace" value="{$namespace}"/>
  -        <input type="hidden" name="uri" value="{source:uri}"/>
  +        <input type="hidden" name="uri" value="{@rdf:about}"/>
           <td align="left">
            <input name="locksubject" type="text" size="25" maxlength="40"/>
           </td>
  @@ -266,22 +242,16 @@
         <xsl:apply-templates select="source:children/rdf:Seq/rdf:li" mode="enumerate"/>
   
         <tr bgcolor="#eeeeee">
  -       <form action="" method="post">
  -        <input type="hidden" name="namespace" value="{$namespace}"/>
  -        <input type="hidden" name="uri" value="{@rdf:about}"/>
  +       <form method="post" enctype="multipart/form-data">
  +       <input type="hidden" name="uri" value="{@rdf:about}"/>
           <td align="left">
  -         <input name="nodename" type="text" size="30" maxlength="40"/>&#160;&#160;
  -         <!--<select name="nodetype">
  -          <option>action</option>
  -          <option>group</option>
  -          <option>link</option>
  -          <option selected="">subject</option>
  -         </select>-->
  +         <input name="filename" type="text" size="25" maxlength="40"/>
           </td>
  -        <td colspan="3" align="left">
  +        <td align="left" colspan="3">
  +         <input type="file" name="file" size="50" />
           </td>
           <td align="right">
  -         <input type="submit" name="cocoon-action-addnode" value="Add"/>
  +         <input type="submit" name="cocoon-action-upload" value="Upload File" />
           </td>
          </form>
         </tr>
  @@ -303,7 +273,6 @@
      <td align="right">
       <xsl:if test="@namespace!='DAV:'">
        <form action="" method="get">
  -      <input type="hidden" name="namespace" value="{$namespace}"/>
         <input type="hidden" name="uri" value="{../../../../source:uri}"/>
         <input type="hidden" name="propertynamespace" value="{@namespace}"/>
         <input type="hidden" name="propertyname" value="{@name}"/>
  @@ -323,7 +292,6 @@
      <td align="left"><tt><xsl:value-of select="@negative"/></tt></td>
      <td align="right">
       <form action="" method="post">
  -     <input type="hidden" name="namespace" value="{$namespace}"/>
        <input type="hidden" name="uri" value="{../../../../@uri}"/>
        <input type="hidden" name="permissionsubject" value="{@subject}"/>
        <input type="hidden" name="permissionsaction" value="{@action}"/>
  @@ -343,7 +311,6 @@
      <td align="left"><tt><xsl:value-of select="@exclusive"/></tt></td>
      <td align="right">
       <form action="" method="post">
  -     <input type="hidden" name="namespace" value="{$namespace}"/>
        <input type="hidden" name="uri" value="{../../../../@uri}"/>
        <input type="hidden" name="locksubject" value="{@subject}"/>
   
  @@ -365,7 +332,6 @@
      <td align="left"><tt><xsl:value-of select="/rdf:RDF/rdf:Description[@rdf:about=$location]/dav:etlastmodified"/></tt></td>
      <td align="right">
       <form action="" method="post">
  -     <input type="hidden" name="namespace" value="{$namespace}"/>
        <input type="hidden" name="uri" value="{../../@rdf:about}"/>
        
        <input type="submit" name="cocoon-action-deletenode" value="Delete"/>
  @@ -384,7 +350,6 @@
      <td align="left"><tt><xsl:value-of select="dav:etlastmodified"/></tt></td>
      <td align="right">
       <form action="" method="post">
  -     <input type="hidden" name="namespace" value="{$namespace}"/>
        <input type="hidden" name="uri" value="{source:uri}"/>
        
        <input type="submit" name="cocoon-action-deletenode" value="Delete"/>
  
  
  
  1.6       +49 -18    xml-cocoon2/src/scratchpad/webapp/mount/slide/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/slide/sitemap.xmap,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- sitemap.xmap	26 Jun 2002 15:08:16 -0000	1.5
  +++ sitemap.xmap	27 Jun 2002 16:53:38 -0000	1.6
  @@ -5,10 +5,10 @@
     <map:generators default="file">
      <map:generator name="sourcedescription" 
                     src="org.apache.cocoon.generation.SourceDescriptionGenerator" 
  -                  logger="sitemap.generator.sourcedescriptiongenerator"/>
  +                  logger="sitemap.generator.sourcedescriptiongenerator"
  +                  label="content"/>
     </map:generators>
   
  -  <map:serializers default="html"/>
     <map:transformers default="xslt">
      <map:transformer name="session" logger="sitemap.transformer.session"
                       src="org.apache.cocoon.webapps.session.transformation.SessionTransformer"/>
  @@ -16,11 +16,31 @@
                       src="org.apache.cocoon.transformation.SourceWritingTransformer"/>
     </map:transformers>
   
  +  <map:serializers default="html">
  +   <map:serializer logger="sitemap.serializer.xml" mime-type="text/xml" name="xml"
  +                   src="org.apache.cocoon.serialization.XMLSerializer"/>
  +
  +   <map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" 
  +                   pool-grow="4" pool-max="32" pool-min="4" 
  +                   src="org.apache.cocoon.serialization.HTMLSerializer">
  +    <buffer-size>1024</buffer-size>
  +   </map:serializer>
  +  </map:serializers>
  +
     <map:readers default="resource"/>
     <map:matchers default="wildcard"/>
     <map:selectors default="browser"/>
   
     <map:actions>
  +   <map:action logger="sitemap.action.slide.upload" name="slide-upload"
  +               src="org.apache.cocoon.acting.SourceUploadAction"/>
  +   <map:action logger="sitemap.action.slide.addproperty" name="slide-addproperty"
  +               src="org.apache.cocoon.acting.SourceAddPropertyAction"/>
  +   <map:action logger="sitemap.action.slide.deleteproperty" name="slide-deleteproperty"
  +               src="org.apache.cocoon.acting.SourceDeletePropertyAction"/>
  +   <map:action logger="sitemap.action.slide.deletecontent" name="slide-deletecontent"
  +               src="org.apache.cocoon.acting.SourceDeleteContentAction"/>
  +
      <map:action name="portal-auth" src="org.apache.cocoon.webapps.portal.acting.AuthAction"/>
   
      <map:action name="auth-protect" logger="sitemap.action.auth-protect" 
  @@ -44,6 +64,30 @@
   
    </map:components>
   
  + <map:views>
  +  <map:view name="content" from-label="content">
  +   <map:transform src="context://samples/common/style/xsl/html/simple-xml2html.xsl"/>
  +   <map:serialize type="html">
  +    <encoding>ASCII</encoding>
  +   </map:serialize>
  +  </map:view>
  +
  +  <map:view name="xml" from-label="content">
  +   <map:serialize type="xml">
  +    <encoding>ASCII</encoding>
  +   </map:serialize>
  +  </map:view>
  + </map:views>
  +
  +  <map:action-sets>
  +   <map:action-set name="slide-actions">
  +    <map:act action="upload"         type="slide-upload"/>
  +    <map:act action="addproperty"    type="slide-addproperty"/>
  +    <map:act action="deleteproperty" type="slide-deleteproperty"/>
  +    <map:act action="deletecontent" type="slide-deletecontent"/>
  +   </map:action-set>
  +  </map:action-sets>
  +
    <map:pipelines>
   
   <!--  <map:pipeline>
  @@ -103,6 +147,8 @@
        <map:parameter name="handler" value="slidehandler"/>-->
   
        <map:match pattern="browse/**">
  +      <map:act set="slide-actions"/>
  +
         <map:generate type="sourcedescription" src="slide://{1}?principal=root">
          <map:parameter name="repository" value="slide"/>
          <map:parameter name="namespace" value="myrepository"/>
  @@ -114,22 +160,7 @@
          <!--<map:parameter name="namespace" value="{1}"/>-->
         </map:transform>
   
  -      <map:serialize type="html"/>
  -     </map:match>
  -
  -     <map:match pattern="test">
  -      <map:generate type="sourcedescription" src="slide://?principal=root">
  -       <map:parameter name="repository" value="slide"/>
  -       <map:parameter name="namespace" value="myrepository"/>
  -       <map:parameter name="principal" value="root"/>
  -      </map:generate>
  -
  -      <!--<map:transform src="rdf2html.xsl">
  -       <map:parameter name="use-request-parameters" value="true"/>
  -       <map:parameter name="namespace" value="{1}"/>
  -      </map:transform>-->
  -
  -      <map:serialize type="html"/>
  +      <map:serialize type="html" mime-type="text/html"/>
        </map:match>
   
        <map:match pattern="view/**">
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message