Author: nicolas
Date: Wed Jul  9 07:00:22 2008
New Revision: 675174

URL: http://svn.apache.org/viewvc?rev=675174&view=rev
Log:
MRM-869

Modified:
    
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
    
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
    
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
    
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java

Modified: 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java?rev=675174&r1=675173&r2=675174&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
 Wed Jul  9 07:00:22 2008
@@ -88,7 +88,7 @@
     implements RepositoryProxyConnectors, RegistryListener, Initializable
 {
     private Logger log = LoggerFactory.getLogger( 
DefaultRepositoryProxyConnectors.class );
-    
+
     /**
      * @plexus.requirement
      */
@@ -169,7 +169,7 @@
             try
             {
                 File downloadedFile =
-                    transferFile( connector, targetRepository, targetPath, 
localFile, requestProperties );
+                    transferFile( connector, targetRepository, targetPath, 
repository, localFile, requestProperties );
 
                 if ( fileExists( downloadedFile ) )
                 {
@@ -230,7 +230,7 @@
 
             try
             {
-                transferFile( connector, targetRepository, targetPath, 
localRepoFile, requestProperties );
+                transferFile( connector, targetRepository, targetPath, 
repository, localRepoFile, requestProperties );
 
                 if ( hasBeenUpdated( localRepoFile, originalMetadataTimestamp 
) )
                 {
@@ -348,7 +348,7 @@
             long originalMetadataTimestamp = getLastModified( localRepoFile );
             try
             {
-                transferFile( connector, targetRepository, targetPath, 
localRepoFile, requestProperties );
+                transferFile( connector, targetRepository, targetPath, 
repository, localRepoFile, requestProperties );
 
                 if ( hasBeenUpdated( localRepoFile, originalMetadataTimestamp 
) )
                 {
@@ -487,6 +487,7 @@
      * @param connector         the connector configuration to use.
      * @param remoteRepository  the remote repository get the resource from.
      * @param remotePath        the path in the remote repository to the 
resource to get.
+     * @param repository        the managed repository that will hold the file
      * @param localFile         the local file to place the downloaded 
resource into
      * @param requestProperties the request properties to utilize for policy 
handling.
      * @return the local file that was downloaded, or null if not downloaded.
@@ -496,7 +497,7 @@
      * @throws ProxyException       if transfer was unsuccessful.
      */
     private File transferFile( ProxyConnector connector, 
RemoteRepositoryContent remoteRepository, String remotePath,
-                               File localFile, Properties requestProperties )
+                               ManagedRepositoryContent repository, File 
localFile, Properties requestProperties )
         throws ProxyException, NotModifiedException
     {
         String url = remoteRepository.getURL().getUrl();
@@ -560,10 +561,10 @@
             boolean connected = connectToRepository( connector, wagon, 
remoteRepository );
             if ( connected )
             {
-                localFile = transferSimpleFile( wagon, remoteRepository, 
remotePath, localFile );
+                localFile = transferSimpleFile( wagon, remoteRepository, 
remotePath, repository, localFile );
 
-                transferChecksum( wagon, remoteRepository, remotePath, 
localFile, ".sha1" );
-                transferChecksum( wagon, remoteRepository, remotePath, 
localFile, ".md5" );
+                transferChecksum( wagon, remoteRepository, remotePath, 
repository, localFile, ".sha1" );
+                transferChecksum( wagon, remoteRepository, remotePath, 
repository, localFile, ".md5" );
             }
         }
         catch ( NotFoundException e )
@@ -627,12 +628,13 @@
      * @param wagon            the wagon instance (should already be 
connected) to use.
      * @param remoteRepository the remote repository to transfer from.
      * @param remotePath       the remote path to the resource to get.
+     * @param repository       the managed repository that will hold the file
      * @param localFile        the local file that should contain the 
downloaded contents
      * @param type             the type of checksum to transfer (example: 
".md5" or ".sha1")
      * @throws ProxyException if copying the downloaded file into place did 
not succeed.
      */
     private void transferChecksum( Wagon wagon, RemoteRepositoryContent 
remoteRepository, String remotePath,
-                                   File localFile, String type )
+                                   ManagedRepositoryContent repository, File 
localFile, String type )
         throws ProxyException
     {
         String url = remoteRepository.getURL().getUrl() + remotePath;
@@ -646,7 +648,7 @@
         try
         {
             File hashFile = new File( localFile.getAbsolutePath() + type );
-            transferSimpleFile( wagon, remoteRepository, remotePath + type, 
hashFile );
+            transferSimpleFile( wagon, remoteRepository, remotePath + type, 
repository, hashFile );
             log.debug( "Checksum" + type + " Downloaded: " + hashFile );
         }
         catch ( NotFoundException e )
@@ -675,13 +677,14 @@
      * @param wagon            the wagon instance to use.
      * @param remoteRepository the remote repository to use
      * @param remotePath       the remote path to attempt to get
+     * @param repository       the managed repository that will hold the file
      * @param localFile        the local file to save to
      * @return The local file that was transfered.
      * @throws ProxyException if there was a problem moving the downloaded 
file into place.
      * @throws WagonException if there was a problem tranfering the file.
      */
     private File transferSimpleFile( Wagon wagon, RemoteRepositoryContent 
remoteRepository, String remotePath,
-                                     File localFile )
+                                     ManagedRepositoryContent repository, File 
localFile )
         throws ProxyException
     {
         assert ( remotePath != null );
@@ -691,9 +694,8 @@
 
         try
         {
-            localFile.getParentFile().mkdirs();
-            temp = File.createTempFile(localFile.getName() + ".", null, 
localFile.getParentFile());
-            
+            temp = File.createTempFile(localFile.getName() + ".", null, new 
File( repository.getRepoRoot() ));
+
             boolean success = false;
 
             if ( !localFile.exists() )
@@ -849,6 +851,7 @@
             throw new ProxyException( "Unable to overwrite existing target 
file: " + target.getAbsolutePath() );
         }
 
+        target.getParentFile().mkdirs();
         if ( !temp.renameTo( target ) )
         {
             log.warn( "Unable to rename tmp file to its final name... 
resorting to copy command." );
@@ -1004,15 +1007,15 @@
     {
         /* do nothing */
     }
-    
+
     private void logProcess( String managedRepoId, String resource, String 
event )
     {
-        
+
     }
-    
+
     private void logRejection( String managedRepoId, String remoteRepoId, 
String resource, String reason )
     {
-        
+
     }
 
     private void initConnectorsAndNetworkProxies()

Modified: 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java?rev=675174&r1=675173&r2=675174&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
 Wed Jul  9 07:00:22 2008
@@ -88,7 +88,7 @@
     protected static final String REPOPATH_LEGACY_MANAGED = 
"src/test/repositories/legacy-managed";
 
     protected static final String REPOPATH_LEGACY_MANAGED_TARGET = 
"target/test-repository/legacy-managed";
-    
+
     protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new 
ArgumentsMatcher() {
 
         public boolean matches(Object[] expected, Object[] actual) {
@@ -103,10 +103,10 @@
             return ArrayUtils.toString(arguments);
         }
     };
-    
+
     protected static final ArgumentsMatcher customWagonGetMatcher = new 
ArgumentsMatcher() {
 
-            public boolean matches(Object[] expected, Object[] actual) 
+            public boolean matches(Object[] expected, Object[] actual)
             {
                 if (expected.length == 2 && actual.length == 2)
                 {
@@ -114,23 +114,23 @@
                     {
                         return true;
                     }
-                    
+
                     if (expected[0] == null)
                     {
                         return actual[0] == null;
                     }
-                    
+
                     if (actual[0] == null)
                     {
                         return expected[0] == null;
                     }
-                    
+
                     return expected[0].equals(actual[0]);
                 }
                 return false;
             }
 
-            public String toString(Object[] arguments) 
+            public String toString(Object[] arguments)
             {
                 return ArrayUtils.toString(arguments);
             }
@@ -540,6 +540,9 @@
             FileUtils.deleteDirectory( destDir );
         }
 
+        // Make the destination dir.
+        destDir.mkdirs();
+
         // Test the source dir.
         if ( !sourceDir.exists() )
         {
@@ -555,9 +558,6 @@
             fail( "Unable to setup testable managed repository, source is not 
a directory: " + sourceDir );
         }
 
-        // Make the destination dir.
-        destDir.mkdirs();
-
         // Copy directory structure.
         copyDirectoryStructure( sourceDir, destDir );
     }

Modified: 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java?rev=675174&r1=675173&r2=675174&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
 Wed Jul  9 07:00:22 2008
@@ -63,11 +63,11 @@
                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES );
         saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, 
ReleasesPolicy.ALWAYS,
                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES );
-        
+
         wagonMock.get( path, new File( expectedFile.getParentFile(), 
expectedFile.getName() + ".tmp" ) );
-        
+
         wagonMockControl.setMatcher(customWagonGetMatcher);
-        
+
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( 
"resource does not exist." ), 2 );
 
         wagonMockControl.replay();
@@ -75,11 +75,11 @@
         File downloadedFile = proxyHandler.fetchFromProxies( 
managedDefaultRepository, artifact );
 
         wagonMockControl.verify();
-        
-               // Second attempt to download same artifact use cache
+
+        // Second attempt to download same artifact use cache
         wagonMockControl.reset();
         wagonMockControl.replay();
-               downloadedFile = proxyHandler.fetchFromProxies( 
managedDefaultRepository, artifact );
+        downloadedFile = proxyHandler.fetchFromProxies( 
managedDefaultRepository, artifact );
         wagonMockControl.verify();
 
         assertNotDownloaded( downloadedFile );
@@ -108,7 +108,7 @@
                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
 
         wagonMock.get( path, new File( expectedFile.getParentFile(), 
expectedFile.getName() + ".tmp" ) );
-        
+
         wagonMockControl.setMatcher(customWagonGetMatcher);
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( 
"resource does not exist." ), 2 );
 
@@ -118,15 +118,15 @@
 
         wagonMockControl.verify();
 
-               // Second attempt to download same artifact DOES NOT use cache
+        // Second attempt to download same artifact DOES NOT use cache
         wagonMockControl.reset();
         wagonMock.get( path, new File( expectedFile.getParentFile(), 
expectedFile.getName() + ".tmp" ) );
-        
+
         wagonMockControl.setMatcher(customWagonGetMatcher);
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( 
"resource does not exist." ), 2 );
         wagonMockControl.replay();
 
-       downloadedFile = proxyHandler.fetchFromProxies( 
managedDefaultRepository, artifact );
+        downloadedFile = proxyHandler.fetchFromProxies( 
managedDefaultRepository, artifact );
 
         wagonMockControl.verify();
 
@@ -138,6 +138,7 @@
         throws Exception
     {
         String path = 
"org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
+        setupTestableManagedRepository( path );
         File expectedFile = new File( managedDefaultDir, path );
         ArtifactReference artifact = 
managedDefaultRepository.toArtifactReference( path );
 

Modified: 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java?rev=675174&r1=675173&r2=675174&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java
 Wed Jul  9 07:00:22 2008
@@ -551,7 +551,7 @@
 
     private File createExpectedTempFile( File expectedFile )
     {
-        return new File( expectedFile.getParentFile(), expectedFile.getName() 
+ ".tmp" ).getAbsoluteFile();
+        return new File( managedDefaultDir, expectedFile.getName() + ".tmp" 
).getAbsoluteFile();
     }
 
     private void confirmSingleFailure( String path, String id )


Reply via email to