mcconnell    2003/11/23 06:10:14

  Modified:    repository/api/src/java/org/apache/avalon/repository/meta
                        Meta.java TargetMeta.java
               repository/impl/src/java/org/apache/avalon/repository/impl
                        defaults.properties
               repository/main maven.xml
               repository/main/src/java/org/apache/avalon/repository
                        InitialRepositoryFactory.java
               repository/test maven.xml
               repository/test/conf test.meta
               repository/test/src/test/org/apache/avalon/repository
                        InitialRepositoryFactoryTest.java LoaderTest.java
               repository/util/src/java/org/apache/avalon/repository/util
                        LOADER.java
  Added:       repository/api/src/java/org/apache/avalon/repository/meta
                        MetaException.java
               repository/api/src/test/org/apache/avalon/repository/meta
                        MetaTest.java
  Log:
  Resolution of a bug caussed by a precision missmatch between file last modification 
dates a url connection last modification dates (files have a precision 1000 higer) 
that was causing duplicated downloads.
  
  Revision  Changes    Path
  1.2       +45 -13    
avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/meta/Meta.java
  
  Index: Meta.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/meta/Meta.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Meta.java 23 Nov 2003 02:00:43 -0000      1.1
  +++ Meta.java 23 Nov 2003 14:10:14 -0000      1.2
  @@ -91,21 +91,53 @@
        * @param domain the domain value
        * @param classifier the classifier value
        * @param version the meta data version
  +     * @exception NullPointerException if the domain, classifier
  +     *   or version attribute is undefined
        */
       public Meta( Attributes attributes ) 
  -      throws NamingException, NoSuchElementException
  +      throws MetaException
       {
  -        c_domain = getValue( attributes, DOMAIN_KEY );
  -        if( null == c_domain ) 
  -           throw new NullPointerException( DOMAIN_KEY );
  +        if( null == attributes )
  +          throw new NullPointerException( "attributes" );
   
  -        c_classifier = getValue( attributes, CLASSIFIER_KEY );
  -        if( null == c_classifier ) 
  -           throw new NullPointerException( CLASSIFIER_KEY );
  +        try
  +        {
  +            c_domain = getValue( attributes, DOMAIN_KEY );
  +            if( null == c_domain ) 
  +            {
  +                final String error = 
  +                  "Missing attribute: " + DOMAIN_KEY;
  +                throw new MetaException( error );
  +            }
   
  -        c_version = getValue( attributes, VERSION_KEY );
  -        if( null == c_version ) 
  -           throw new NullPointerException( VERSION_KEY );
  +            c_classifier = getValue( attributes, CLASSIFIER_KEY );
  +            if( null == c_classifier ) 
  +            {
  +                final String error = 
  +                  "Missing attribute: " + CLASSIFIER_KEY;
  +                throw new MetaException( error );
  +            }
  +
  +            c_version = getValue( attributes, VERSION_KEY );
  +            if( null == c_version ) 
  +            {
  +                final String error = 
  +                  "Missing attribute: " + VERSION_KEY;
  +                throw new MetaException( error );
  +            }
  +        }
  +        catch( NamingException e )
  +        {
  +            final String error = 
  +              "Unexpected naming exception during metadata creation.";
  +            throw new MetaException( error, e );
  +        }
  +        catch( NoSuchElementException e )
  +        {
  +            final String error = 
  +              "Unexpected exception during metadata creation.";
  +            throw new MetaException( error, e );
  +        }
       }
   
       //-----------------------------------------------------------
  
  
  
  1.2       +40 -8     
avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/meta/TargetMeta.java
  
  Index: TargetMeta.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/meta/TargetMeta.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TargetMeta.java   23 Nov 2003 02:00:43 -0000      1.1
  +++ TargetMeta.java   23 Nov 2003 14:10:14 -0000      1.2
  @@ -72,16 +72,16 @@
       //-----------------------------------------------------------
   
       public static final String GROUP_KEY = 
  -      "avalon.target.implementation.group";
  +      "avalon.target.group";
   
       public static final String NAME_KEY = 
  -      "avalon.target.implementation.name";
  +      "avalon.target.name";
   
       public static final String VERSION_KEY = 
  -      "avalon.target.implementation.version";
  +      "avalon.target.version";
   
       public static final String FACTORY_KEY = 
  -      "avalon.target.implementation.factory";
  +      "avalon.target.factory";
   
       //-----------------------------------------------------------
       // immutable state
  @@ -102,11 +102,43 @@
        * @param version the meta data version
        */
       public TargetMeta( final Attributes attributes ) 
  -      throws NamingException, NoSuchElementException
  +      throws MetaException
       {
           super( attributes );
  -        c_factory = getValue( attributes, FACTORY_KEY );
  -        c_implementation = createImplementationArtifact( attributes );
  +        try
  +        {
  +            c_factory = getValue( attributes, FACTORY_KEY );
  +            if( null == c_factory ) 
  +            {
  +                final String error = 
  +                  "Missing attribute: " + FACTORY_KEY;
  +                throw new MetaException( error );
  +            }
  +        }
  +        catch( NamingException ne )
  +        {
  +            final String error = 
  +              "Unexpected naming exception during target metadata creation.";
  +            throw new MetaException( error, ne );
  +        }
  +        catch( NoSuchElementException nee )
  +        {
  +            final String error = 
  +              "Unexpected exception during target metadata creation.";
  +            throw new MetaException( error, nee );
  +        }
  +
  +        try
  +        {
  +            c_implementation = createImplementationArtifact( attributes );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unable to construct target implementation artifact "
  +              + "reference from attributes: " + attributes;
  +            throw new MetaException( error, e );
  +        }
       }
   
       //-----------------------------------------------------------
  
  
  
  1.1                  
avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/meta/MetaException.java
  
  Index: MetaException.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 "Jakarta", "Apache Avalon", "Avalon Framework" 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 [EMAIL PROTECTED]
  
   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. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.repository.meta;
  
  import org.apache.avalon.repository.RepositoryException;
  
  /**
   * Exception to indicate that there was a repository related meta error.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/11/23 14:10:14 $
   */
  public class MetaException extends RepositoryException
  {
      /**
       * Construct a new <code>MetaException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public MetaException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>MetaException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param cause the root cause of the exception
       */
      public MetaException( final String message, final Throwable cause )
      {
          super( message, cause );
      }
  }
  
  
  
  
  1.1                  
avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/meta/MetaTest.java
  
  Index: MetaTest.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 "Jakarta", "Apache Avalon", "Avalon Framework" 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 [EMAIL PROTECTED]
  
   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. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.repository.meta;
  
  import java.util.NoSuchElementException;
  import javax.naming.directory.Attributes;
  import javax.naming.directory.BasicAttributes;
  import javax.naming.directory.Attribute;
  import javax.naming.NamingException;
  
  import junit.framework.TestCase;
  
  
  /**
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class MetaTest extends TestCase
  {
  
      public static void main(String[] args)
      {
          junit.textui.TestRunner.run( MetaTest.class );
      }
  
      /**
       * Constructor for ArtifactReferenceTest.
       * @param arg0
       */
      public MetaTest( String name )
      {
          super( name );
      }
      
      public void testConstructor() throws Exception
      {
          try
          {
              Meta meta = new Meta( null );
              fail( "constructor using null should throw an NPE" );
          }
          catch( NullPointerException e )
          {
              assertTrue( true );
          }
          catch( Throwable e )
          {
              fail( "NPE expected by encountered: " + e );
          }
      }
  
      public void testEmptyAttribute() throws Exception
      {
          Attributes attributes = new BasicAttributes();
          try
          {
              Meta meta = new Meta( attributes );
              fail( "missing attributes should fail" );
          }
          catch( MetaException e )
          {
              assertTrue( true );
          }
          catch( Throwable e )
          {
              fail( "Unexpected error: " + e );
          }
      }
  
      public void testIntegrity() throws Exception
      {
          String domain = "aaa";
          String classifier = "bbb";
          String version = "123";
  
          Attributes attributes = new BasicAttributes();
          attributes.put( Meta.DOMAIN_KEY, domain );
          attributes.put( Meta.CLASSIFIER_KEY, classifier );
          attributes.put( Meta.VERSION_KEY, version );
  
          try
          {
              Meta meta = new Meta( attributes );
              assertEquals( "domain", meta.getDomain(), domain );
              assertEquals( "classifier", meta.getClassifier(), classifier );
              assertEquals( "version", meta.getVersion(), version );
              assertEquals( "equals", meta, meta );
          }
          catch( Throwable e )
          {
              fail( "unexpected error: " + e );
          }
      }
  }
  
  
  
  1.6       +2 -2      
avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/defaults.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- defaults.properties       20 Nov 2003 05:41:00 -0000      1.5
  +++ defaults.properties       23 Nov 2003 14:10:14 -0000      1.6
  @@ -1,5 +1,5 @@
   # Not used at the moment but can be used for defaults discovery 
   # 
   cache.dir=.avalon
  -remote.repository.url.0=http://dpml.net 
  -remote.repository.url.1=http://ibiblio.org/maven 
  +#remote.repository.url.0=http://dpml.net 
  +#remote.repository.url.1=http://ibiblio.org/maven 
  
  
  
  1.6       +10 -17    avalon-sandbox/repository/main/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/maven.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- maven.xml 23 Nov 2003 02:00:43 -0000      1.5
  +++ maven.xml 23 Nov 2003 14:10:14 -0000      1.6
  @@ -18,9 +18,9 @@
   
     <!--
     ###########################################################################
  -  # Create the .meta target metadata.                                              #
  +  # Create the target .meta metadata.                                       #
     # This contains the information used by the factory to identify the       #
  -  # the implementation artifact classpath, factory, and whever else         #
  +  # the implementation artifact classpath, factory, and whatever else       #
     # we need to include this jar as the implementation strategy.             #
     ###########################################################################
     -->
  @@ -32,12 +32,15 @@
       <ant:mkdir dir="${maven.build.dir}/classes/${pom.groupId}"/>
       <ant:echo 
file="${maven.build.dir}/classes/${pom.groupId}/${pom.artifactId}.meta">
   #
  -# Meta classifier.
  -# 
  +# Metadata identification.
  +# This file if generated under the Avalon Repository Main build process.  
  +# It contains a target artifact reference and factory parameters using 
  +# during the bootstrapping of the repository implementation.
  +#
   
   meta.domain = avalon
  -meta.domain.classifier = target
  -meta.domain.classifier.version = 1.0
  +meta.classifier = target
  +meta.version = 1.0
   
   #
   # Repository Implementation target description.
  @@ -46,17 +49,7 @@
   avalon.target.group = ${impl.groupId}
   avalon.target.name = ${impl.artifactId}
   avalon.target.version = ${impl.version}
  -avalon.target.repos = ${maven.repo.remote}
  -
  -#
  -# Factory class and parameters.
  -# (factory methof/constructor/parameters generation pending)
  -#
  -
  -avalon.target.factory.class = 
org.apache.avalon.repository.impl.DefaultRepositoryFactory
  -avalon.target.factory.method = create
  -avalon.target.factory.key.0 = some-key
  -avalon.target.factory.key.1 = another-key
  +avalon.target.factory = org.apache.avalon.repository.impl.DefaultRepositoryFactory
   
   #
   # EOF
  
  
  
  1.11      +2 -3      
avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java
  
  Index: InitialRepositoryFactory.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- InitialRepositoryFactory.java     23 Nov 2003 02:00:43 -0000      1.10
  +++ InitialRepositoryFactory.java     23 Nov 2003 14:10:14 -0000      1.11
  @@ -314,8 +314,7 @@
       private static File setupDefaultCache()
       {
           final File home = new File( System.getProperty( "user.home" ) );
  -        final File avalon = new File( home, ".avalon" ); 
  -        return new File( avalon, ".cache" );
  +        return new File( home, ".avalon" ); 
       }
   
       // ------------------------------------------------------------------------
  
  
  
  1.4       +4 -2      avalon-sandbox/repository/test/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/test/maven.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- maven.xml 23 Nov 2003 02:00:43 -0000      1.3
  +++ maven.xml 23 Nov 2003 14:10:14 -0000      1.4
  @@ -2,14 +2,16 @@
   
     <preGoal name="test:test">
       <ant:mkdir dir="${maven.build.dir}/repository"/>
  -    <copy todir="${maven.build.dir}/repository">
  +    <copy todir="${maven.build.dir}/repository" preserverlastmodified="true">
         <fileset dir="${maven.repo.local}">
           <include name="avalon-repository/**"/>
           <include name="avalon-util/**"/>
           <include name="merlin/**"/>
         </fileset>
       </copy>
  -    <copy file="${basedir}/conf/test.meta" 
toDir="${maven.build.dir}/repository/test"/>
  +    <copy file="${basedir}/conf/test.meta" 
  +      toDir="${maven.build.dir}/repository/test"
  +      preserverlastmodified="true"/>
     </preGoal>
   
   </project>
  
  
  
  1.2       +4 -16     avalon-sandbox/repository/test/conf/test.meta
  
  Index: test.meta
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/test/conf/test.meta,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- test.meta 23 Nov 2003 02:00:43 -0000      1.1
  +++ test.meta 23 Nov 2003 14:10:14 -0000      1.2
  @@ -13,20 +13,8 @@
   # that will be used to establish the principal classloader chain.
   #
   
  -avalon.target.implementation.group = merlin
  -avalon.target.implementation.name = merlin-kernel-impl
  -avalon.target.implementation.version = 3.2.2-dev
  -avalon.target.implementation.factory = 
org.apache.avalon.merlin.kernel.impl.DefaultFactory
  +avalon.target.group = merlin
  +avalon.target.name = merlin-kernel-impl
  +avalon.target.version = 3.2.2-dev
  +avalon.target.factory = org.apache.avalon.merlin.kernel.impl.DefaultFactory
   
  -#
  -# Context builder description.
  -# ----------------------------
  -# The following properties define the group, artifact id, version and
  -# builder class to be used for the parameterization of an particular
  -# embedded scenario.
  -#
  -
  -avalon.target.builder.group = merlin
  -avalon.target.builder.name = merlin-servlet
  -avalon.target.builder.version = 1.0-dev
  -avalon.target.builder.factory = org.apache.avalon.merlin.servlet.MerlinBuilder
  
  
  
  1.8       +8 -10     
avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/InitialRepositoryFactoryTest.java
  
  Index: InitialRepositoryFactoryTest.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/InitialRepositoryFactoryTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InitialRepositoryFactoryTest.java 23 Nov 2003 02:00:43 -0000      1.7
  +++ InitialRepositoryFactoryTest.java 23 Nov 2003 14:10:14 -0000      1.8
  @@ -74,11 +74,11 @@
   
       /**
        * Constructor for InitialRepositoryFactoryTest.
  -     * @param arg0
  +     * @param name the test name
        */
  -    public InitialRepositoryFactoryTest(String arg0)
  +    public InitialRepositoryFactoryTest( String name )
       {
  -        super(arg0);
  +        super( name );
       }
   
       public void testRepositoryBootstrap() throws Exception
  @@ -98,7 +98,7 @@
           assertNotNull( repository ) ;
           
           repository.getArtifact( 
  -          "avalon-framework", "avalon-framework-api", "4.1.5", "jar" ) ;
  +          "avalon-framework", "avalon-framework-api", "4.1.5", "jar" );
       }
   
       public void testClassloaderCreation() throws Exception
  @@ -138,11 +138,8 @@
           // create a classloader based on the artifact
           //
   
  -        long time = System.currentTimeMillis();
           ClassLoader loader = 
             repository.getClassLoader( artifact );
  -        long time2 = System.currentTimeMillis();
  -        System.out.println("## elapsed: (" + (time2 - time) + " milliseconds)" );
   
           //
           // grab a class from the classloader just to show that 
  @@ -164,7 +161,9 @@
       private static String[] getWorkingRepositorySet()
       {
           return new String[]{ 
  -          "http://dpml.net/","http://www.ibiblio.org/maven/";
  +          "file:///" + System.getProperty( "basedir" ) + "/target/repository",
  +          "http://dpml.net/";,
  +          "http://www.ibiblio.org/maven/";
           };
       }
   
  @@ -174,5 +173,4 @@
              + File.separator + ".cache" 
              + File.separator + "repository";
       }
  -
   }
  
  
  
  1.3       +1 -8      
avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/LoaderTest.java
  
  Index: LoaderTest.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/LoaderTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LoaderTest.java   23 Nov 2003 02:26:01 -0000      1.2
  +++ LoaderTest.java   23 Nov 2003 14:10:14 -0000      1.3
  @@ -169,13 +169,6 @@
           };
       }
   
  -    private String getCacheDir()
  -    {
  -        return System.getProperty( "user.dir" ) 
  -           + File.separator + ".cache" 
  -           + File.separator + "repository";
  -    }
  -
       private File getBaseDirectory()
       {
           String work = System.getProperty( "user.dir" );
  
  
  
  1.2       +33 -17    
avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/LOADER.java
  
  Index: LOADER.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/LOADER.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LOADER.java       20 Nov 2003 04:25:30 -0000      1.1
  +++ LOADER.java       23 Nov 2003 14:10:14 -0000      1.2
  @@ -146,6 +146,10 @@
         String url, File destination, boolean timestamping ) 
         throws Exception
       {
  +
  +        boolean update = destination.exists();
  +        long remoteTimestamp = 0; // remote
  +
           //
           // if timestamp is enabled and the destination file exists and 
           // the source is a file - then do a quick check using native File
  @@ -163,6 +167,16 @@
                   {
                       return destination.toURL();
                   }
  +                else
  +                {
  +                    //
  +                    // set the remote tamestamp here because the pricision
  +                    // for a file last modification date is higher then the 
  +                    // connection last mosification date
  +                    //
  +
  +                    remoteTimestamp = sourceFile.lastModified();
  +                }
               }
               catch( Throwable e )
               {
  @@ -276,7 +290,14 @@
           byte[] buffer = new byte[100 * 1024] ;
           int length ;
   
  -        System.out.print( "Source: " + source + "\n") ;
  +        if( update )
  +        {
  +            System.out.print( "Updating: [" + source + "] ") ;
  +        }
  +        else
  +        {
  +            System.out.print( "Creating: [" + source + "] ") ;
  +        }
           while ( ( length = in.read( buffer ) ) >= 0 )
           {
               out.write( buffer, 0, length ) ;
  @@ -293,25 +314,20 @@
   
           if ( timestamping )
           {
  -            long remoteTimestamp = connection.getLastModified() ;
  -
  -            if ( remoteTimestamp != 0 )
  +            if( remoteTimestamp == 0 )
               {
  -                long modifiedTime ;
  -
  -                if ( remoteTimestamp  < 0 )
  -                {
  -                    modifiedTime = System.currentTimeMillis() ;
  -                }
  -                else
  -                {
  -                    modifiedTime = remoteTimestamp  ;
  -                }
  +                remoteTimestamp = connection.getLastModified() ;
  +            }
   
  -                destination.setLastModified( modifiedTime ) ;
  +            if( remoteTimestamp  < 0 )
  +            {
  +                destination.setLastModified( System.currentTimeMillis() ) ;
  +            }
  +            else
  +            {
  +                destination.setLastModified( remoteTimestamp ) ;
               }
           }
  -        
           return destination.toURL();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to