cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/acting CopySourceAction.java
Date Sat, 20 Dec 2003 14:29:19 GMT
sylvain     2003/12/20 06:29:19

  Modified:    src/java/org/apache/cocoon/acting CopySourceAction.java
  Log:
  Handle directories as the destination
  
  Revision  Changes    Path
  1.2       +17 -1     cocoon-2.1/src/java/org/apache/cocoon/acting/CopySourceAction.java
  
  Index: CopySourceAction.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/acting/CopySourceAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopySourceAction.java	5 Nov 2003 17:18:00 -0000	1.1
  +++ CopySourceAction.java	20 Dec 2003 14:29:19 -0000	1.2
  @@ -58,10 +58,12 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.cocoon.components.source.impl.PartSource;
   import org.apache.cocoon.environment.Redirector;
   import org.apache.excalibur.source.ModifiableSource;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
  +import org.apache.excalibur.source.TraversableSource;
   
   /**
    * The CopySourceAction copies the content of it's "src" attribute to its "dest" parameter.
  @@ -98,6 +100,20 @@
           // Check that dest is writeable
           if (! (dest instanceof ModifiableSource)) {
               throw new IllegalArgumentException("Non-writeable URI : " + dest.getURI());
  +        }
  +        
  +        if (dest instanceof TraversableSource) {
  +            TraversableSource trDest = (TraversableSource) dest;
  +            if (trDest.isCollection()) {
  +                if (src instanceof TraversableSource) {
  +                    dest = trDest.getChild(((TraversableSource)src).getName());
  +                } else if (src instanceof PartSource){
  +                    // FIXME : quick hack to store "upload://xxx" sources into directories
  +                    // it would be better for the PartSource to be Traversable, or to
  +                    // create a new "NamedSource" interface
  +                    dest = trDest.getChild(((PartSource)src).getPart().getFileName());
  +                }
  +            }
           }
           
           ModifiableSource wdest = (ModifiableSource)dest;
  
  
  

Mime
View raw message