maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csta...@apache.org
Subject svn commit: r1053381 - in /maven/indexer/trunk/indexer-core/src: main/java/org/apache/maven/index/ main/java/org/apache/maven/index/cli/ main/java/org/apache/maven/index/context/ main/java/org/apache/maven/index/incremental/ main/java/org/apache/maven/...
Date Tue, 28 Dec 2010 16:14:47 GMT
Author: cstamas
Date: Tue Dec 28 16:14:47 2010
New Revision: 1053381

URL: http://svn.apache.org/viewvc?rev=1053381&view=rev
Log:
Major improvement: making IndexingContexts able to receive remote updates, index local content and publish downstream. Some other smaller fixes.

* before this change, a context was able only to serve as "update only", or "publish only" but not both (unless circumvented with some heavy trickery and tampering with internals). Now, contexts are happy to receive remote updates, maintain local content (cache content in this very case), and publish properly downstream.
* proper handling of "full" reindex and "update" reindex
* cleanup of scattered remote index file names creation.

Modified:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexUtils.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexingContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/AbstractResourceFetcher.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdater.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/WagonHelper.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java Tue Dec 28 16:14:47 2010
@@ -158,12 +158,13 @@ public class DefaultNexusIndexer
     }
 
     public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
-                                                     boolean searchable, Collection<IndexingContext> contexts )
+                                                     File indexDirectory, boolean searchable,
+                                                     Collection<IndexingContext> contexts )
         throws IOException
     {
         IndexingContext context =
-            new MergedIndexingContext( id, repositoryId, repository, searchable, new StaticContextMemberProvider(
-                contexts ) );
+            new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
+                new StaticContextMemberProvider( contexts ) );
 
         indexingContexts.put( context.getId(), context );
 
@@ -171,10 +172,12 @@ public class DefaultNexusIndexer
     }
 
     public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
-                                                     boolean searchable, ContextMemberProvider membersProvider )
+                                                     File indexDirectory, boolean searchable,
+                                                     ContextMemberProvider membersProvider )
         throws IOException
     {
-        IndexingContext context = new MergedIndexingContext( id, repositoryId, repository, searchable, membersProvider );
+        IndexingContext context =
+            new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
 
         indexingContexts.put( context.getId(), context );
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java Tue Dec 28 16:14:47 2010
@@ -122,14 +122,14 @@ class DefaultScannerListener
                 listener.artifactDiscovered( ac );
             }
 
-            // if ( adding )
-            // {
-            indexerEngine.index( context, ac );
-            // }
-            // else
-            // {
-            // indexerEngine.update( context, ac );
-            // }
+            if ( adding )
+            {
+                indexerEngine.index( context, ac );
+            }
+            else
+            {
+                indexerEngine.update( context, ac );
+            }
 
             for ( Exception e : ac.getErrors() )
             {
@@ -164,7 +164,7 @@ class DefaultScannerListener
 
             context.setAllGroups( allGroups );
 
-            if ( update )
+            if ( update && !context.isReceivingUpdates() )
             {
                 removeDeletedArtifacts( context, result );
             }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java Tue Dec 28 16:14:47 2010
@@ -169,12 +169,12 @@ public interface NexusIndexer
                                               List<? extends IndexCreator> indexers )
         throws IOException;
 
-    IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, boolean searchable,
-                                              Collection<IndexingContext> contexts )
+    IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
+                                              boolean searchable, Collection<IndexingContext> contexts )
         throws IOException;
 
-    IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, boolean searchable,
-                                              ContextMemberProvider membersProvider )
+    IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
+                                              boolean searchable, ContextMemberProvider membersProvider )
         throws IOException;
 
     /**
@@ -317,7 +317,7 @@ public interface NexusIndexer
     // throws ParseException;
 
     // ----------------------------------------------------------------------------
-    // Identification 
+    // Identification
     // Since 4.0: Indexer does not make any assumptions, it is caller call to decide what to do with multiple results
     // ----------------------------------------------------------------------------
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java Tue Dec 28 16:14:47 2010
@@ -399,7 +399,7 @@ public class NexusIndexerCli
     {
         final String indexDirectoryName = cli.getOptionValue( INDEX, "." );
         final File indexFolder = new File( indexDirectoryName ).getCanonicalFile();
-        final File indexArchive = new File( indexFolder, IndexingContext.INDEX_FILE + ".gz" );
+        final File indexArchive = new File( indexFolder, IndexingContext.INDEX_FILE_PREFIX + ".gz" );
 
         final String outputDirectoryName = cli.getOptionValue( TARGET_DIR, "." );
         final File outputFolder = new File( outputDirectoryName ).getCanonicalFile();

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java Tue Dec 28 16:14:47 2010
@@ -57,7 +57,7 @@ import org.codehaus.plexus.util.StringUt
  * @author Tamas Cservenak
  */
 public class DefaultIndexingContext
-    implements IndexingContext
+    extends AbstractIndexingContext
 {
     /**
      * A standard location for indices served up by a webserver.
@@ -262,7 +262,7 @@ public class DefaultIndexingContext
                 IndexWriter.unlock( indexDirectory );
             }
 
-            deleteIndexFiles();
+            deleteIndexFiles( true );
         }
 
         openAndWarmup();
@@ -347,7 +347,7 @@ public class DefaultIndexingContext
         w.commit();
     }
 
-    private void deleteIndexFiles()
+    private void deleteIndexFiles( boolean full )
         throws IOException
     {
         String[] names = indexDirectory.listAll();
@@ -365,6 +365,19 @@ public class DefaultIndexingContext
             }
         }
 
+        if ( full )
+        {
+            if ( indexDirectory.fileExists( INDEX_PACKER_PROPERTIES_FILE ) )
+            {
+                indexDirectory.deleteFile( INDEX_PACKER_PROPERTIES_FILE );
+            }
+
+            if ( indexDirectory.fileExists( INDEX_UPDATER_PROPERTIES_FILE ) )
+            {
+                indexDirectory.deleteFile( INDEX_UPDATER_PROPERTIES_FILE );
+            }
+        }
+
         IndexUtils.deleteTimestamp( indexDirectory );
     }
 
@@ -751,7 +764,7 @@ public class DefaultIndexingContext
 
                 if ( deleteFiles )
                 {
-                    deleteIndexFiles();
+                    deleteIndexFiles( true );
                 }
 
                 indexDirectory.close();
@@ -776,7 +789,7 @@ public class DefaultIndexingContext
         {
             closeReaders();
 
-            deleteIndexFiles();
+            deleteIndexFiles( true );
 
             openAndWarmup();
 
@@ -810,11 +823,9 @@ public class DefaultIndexingContext
 
             closeReaders();
 
-            deleteIndexFiles();
+            deleteIndexFiles( false );
 
-            Directory.copy( directory, indexDirectory, false );
-            // We do it manually here, since we do want delete to happen 1st
-            // IndexUtils.copyDirectory( directory, indexDirectory );
+            IndexUtils.copyDirectory( directory, indexDirectory );
 
             openAndWarmup();
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexUtils.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexUtils.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexUtils.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexUtils.java Tue Dec 28 16:14:47 2010
@@ -38,6 +38,8 @@ public class IndexUtils
 {
     public static final String TIMESTAMP_FILE = "timestamp";
 
+    private static final int BUFFER_SIZE = 16384;
+
     // Directory
 
     public static void copyDirectory( Directory source, Directory target )
@@ -47,10 +49,59 @@ public class IndexUtils
         // copied in 2.9)
         Directory.copy( source, target, false );
 
+        copyFile( source, target, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE );
+        copyFile( source, target, IndexingContext.INDEX_PACKER_PROPERTIES_FILE );
+
         Date ts = getTimestamp( source );
         updateTimestamp( target, ts );
     }
 
+    public static boolean copyFile( Directory source, Directory target, String name )
+        throws IOException
+    {
+        return copyFile( source, target, name, name );
+    }
+
+    public static boolean copyFile( Directory source, Directory target, String srcName, String targetName )
+        throws IOException
+    {
+        if ( !source.fileExists( srcName ) )
+        {
+            return false;
+        }
+
+        byte[] buf = new byte[BUFFER_SIZE];
+
+        IndexInput is = null;
+        IndexOutput os = null;
+
+        try
+        {
+            is = source.openInput( srcName );
+
+            os = target.createOutput( targetName );
+
+            // and copy to dest directory
+            long len = is.length();
+            long readCount = 0;
+            while ( readCount < len )
+            {
+                int toRead = readCount + BUFFER_SIZE > len ? (int) ( len - readCount ) : BUFFER_SIZE;
+                is.readBytes( buf, 0, toRead );
+                os.writeBytes( buf, toRead );
+                readCount += toRead;
+            }
+
+            return true;
+        }
+        finally
+        {
+            close( os );
+
+            close( is );
+        }
+    }
+
     // timestamp
 
     public static ArtifactInfo constructArtifactInfo( Document doc, IndexingContext context )

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexingContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexingContext.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexingContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/IndexingContext.java Tue Dec 28 16:14:47 2010
@@ -46,7 +46,13 @@ public interface IndexingContext
      * Standard name of the full repository index that is used when clients requesting index information have nothing to
      * start with.
      */
-    public static final String INDEX_FILE = "nexus-maven-repository-index";
+    public static final String INDEX_FILE_PREFIX = "nexus-maven-repository-index";
+
+    public static final String INDEX_REMOTE_PROPERTIES_FILE = INDEX_FILE_PREFIX + ".properties";
+
+    public static final String INDEX_UPDATER_PROPERTIES_FILE = INDEX_FILE_PREFIX + "-updater.properties";
+
+    public static final String INDEX_PACKER_PROPERTIES_FILE = INDEX_FILE_PREFIX + "-packer.properties";
 
     /**
      * A prefix used for all index property names
@@ -313,4 +319,10 @@ public interface IndexingContext
     void rebuildGroups()
         throws IOException;
 
+    /**
+     * Returns true if this context is receiving updates from remote via IndexUpdater.
+     * 
+     * @return
+     */
+    boolean isReceivingUpdates();
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java Tue Dec 28 16:14:47 2010
@@ -15,7 +15,7 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.index.MultiReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.FSDirectory;
 import org.apache.maven.index.artifact.GavCalculator;
 import org.apache.maven.index.artifact.M2GavCalculator;
 
@@ -26,7 +26,7 @@ import org.apache.maven.index.artifact.M
  * @author cstamas
  */
 public class MergedIndexingContext
-    implements IndexingContext
+    extends AbstractIndexingContext
 {
     private final String id;
 
@@ -40,12 +40,12 @@ public class MergedIndexingContext
 
     private final Directory directory;
 
-    private final File directoryFile;
+    private File directoryFile;
 
     private boolean searchable;
 
-    public MergedIndexingContext( String id, String repositoryId, File repository, boolean searchable,
-                                  ContextMemberProvider membersProvider )
+    private MergedIndexingContext( ContextMemberProvider membersProvider, String id, String repositoryId,
+                                   File repository, Directory indexDirectory, boolean searchable )
         throws IOException
     {
         this.id = id;
@@ -53,13 +53,31 @@ public class MergedIndexingContext
         this.repository = repository;
         this.membersProvider = membersProvider;
         this.gavCalculator = new M2GavCalculator();
-        this.directory = new RAMDirectory(); // needed since publisher requires it, but is not used
-        this.directoryFile = File.createTempFile( "merged-index", ".dir" ); // neded since publisher requires it, but is not used
-        this.directoryFile.delete();
-        this.directoryFile.mkdirs();
+        this.directory = indexDirectory;
         this.searchable = searchable;
     }
 
+    public MergedIndexingContext( String id, String repositoryId, File repository, File indexDirectoryFile,
+                                  boolean searchable, ContextMemberProvider membersProvider )
+        throws IOException
+    {
+        this( membersProvider, id, repositoryId, repository, FSDirectory.open( indexDirectoryFile ), searchable );
+
+        this.directoryFile = indexDirectoryFile;
+    }
+
+    public MergedIndexingContext( String id, String repositoryId, File repository, Directory indexDirectory,
+                                  boolean searchable, ContextMemberProvider membersProvider )
+        throws IOException
+    {
+        this( membersProvider, id, repositoryId, repository, indexDirectory, searchable );
+
+        if ( indexDirectory instanceof FSDirectory )
+        {
+            this.directoryFile = ( (FSDirectory) indexDirectory ).getFile();
+        }
+    }
+
     protected Collection<IndexingContext> getMembers()
     {
         return membersProvider.getMembers();

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java Tue Dec 28 16:14:47 2010
@@ -96,7 +96,7 @@ public class DefaultIncrementalHandler
 
             while ( currentCounter <= maxCounter )
             {
-                filenames.add( IndexingContext.INDEX_FILE + "." + currentCounter++ + ".gz" );
+                filenames.add( IndexingContext.INDEX_FILE_PREFIX + "." + currentCounter++ + ".gz" );
             }
         }
 
@@ -225,7 +225,7 @@ public class DefaultIncrementalHandler
             {
                 String[] parts = name.split( "\\." );
 
-                if ( parts.length == 3 && parts[0].equals( IndexingContext.INDEX_FILE ) && parts[2].equals( "gz" ) )
+                if ( parts.length == 3 && parts[0].equals( IndexingContext.INDEX_FILE_PREFIX ) && parts[2].equals( "gz" ) )
                 {
                     return true;
                 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java Tue Dec 28 16:14:47 2010
@@ -101,8 +101,8 @@ public class DefaultIndexPacker
         }
 
         // These are all of the files we'll be dealing with (except for the incremental chunks of course)
-        File legacyFile = new File( request.getTargetDir(), IndexingContext.INDEX_FILE + ".zip" );
-        File v1File = new File( request.getTargetDir(), IndexingContext.INDEX_FILE + ".gz" );
+        File legacyFile = new File( request.getTargetDir(), IndexingContext.INDEX_FILE_PREFIX + ".zip" );
+        File v1File = new File( request.getTargetDir(), IndexingContext.INDEX_FILE_PREFIX + ".gz" );
 
         Properties info = null;
 
@@ -129,8 +129,8 @@ public class DefaultIndexPacker
                 {
                     File file =
                         new File( request.getTargetDir(), //
-                            IndexingContext.INDEX_FILE + "." + info.getProperty( IndexingContext.INDEX_CHUNK_COUNTER )
-                                + ".gz" );
+                            IndexingContext.INDEX_FILE_PREFIX + "."
+                                + info.getProperty( IndexingContext.INDEX_CHUNK_COUNTER ) + ".gz" );
 
                     writeIndexData( request.getContext(), //
                         chunk, file );
@@ -206,11 +206,12 @@ public class DefaultIndexPacker
 
         if ( request.isUseTargetProperties() )
         {
-            file = new File( request.getTargetDir(), IndexingContext.INDEX_FILE + ".properties" );
+            file = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE );
         }
         else
         {
-            file = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_FILE + ".properties" );
+            file =
+                new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE );
         }
 
         Properties properties = new Properties();
@@ -436,8 +437,8 @@ public class DefaultIndexPacker
         throws IOException
     {
         File propertyFile =
-            new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_FILE + ".properties" );
-        File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_FILE + ".properties" );
+            new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE );
+        File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE );
 
         info.setProperty( IndexingContext.INDEX_ID, request.getContext().getId() );
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/AbstractResourceFetcher.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/AbstractResourceFetcher.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/AbstractResourceFetcher.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/AbstractResourceFetcher.java Tue Dec 28 16:14:47 2010
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 
+@Deprecated
 public abstract class AbstractResourceFetcher
     implements ResourceFetcher
 {

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java Tue Dec 28 16:14:47 2010
@@ -173,22 +173,6 @@ public class DefaultIndexUpdater
         return result;
     }
 
-    public Properties fetchIndexProperties( final IndexingContext context, final ResourceFetcher fetcher )
-        throws IOException
-    {
-        fetcher.connect( context.getId(), context.getIndexUpdateUrl() );
-        try
-        {
-            Properties properties = downloadIndexProperties( fetcher );
-            storeIndexProperties( context.getIndexDirectoryFile(), properties );
-            return properties;
-        }
-        finally
-        {
-            fetcher.disconnect();
-        }
-    }
-
     private Date loadIndexDirectory( final IndexUpdateRequest updateRequest, final ResourceFetcher fetcher,
                                      final boolean merge, final String remoteIndexFile )
         throws IOException
@@ -417,11 +401,9 @@ public class DefaultIndexUpdater
         }
     }
 
-    private Properties loadIndexProperties( final File indexDirectoryFile )
+    private Properties loadIndexProperties( final File indexDirectoryFile, final String remoteIndexPropertiesName )
     {
-        String remoteIndexProperties = IndexingContext.INDEX_FILE + ".properties";
-
-        File indexProperties = new File( indexDirectoryFile, remoteIndexProperties );
+        File indexProperties = new File( indexDirectoryFile, remoteIndexPropertiesName );
 
         FileInputStream fis = null;
 
@@ -447,28 +429,11 @@ public class DefaultIndexUpdater
         return null;
     }
 
-    private Properties downloadIndexProperties( final ResourceFetcher fetcher )
+    private void storeIndexProperties( final File dir, final String indexPropertiesName, final Properties properties )
         throws IOException
     {
-        InputStream fis = fetcher.retrieve( IndexingContext.INDEX_FILE + ".properties" );
-        try
-        {
-            Properties properties = new Properties();
-
-            properties.load( fis );
+        File file = new File( dir, indexPropertiesName );
 
-            return properties;
-        }
-        finally
-        {
-            IOUtil.close( fis );
-        }
-    }
-
-    private void storeIndexProperties( final File dir, final Properties properties )
-        throws IOException
-    {
-        File file = new File( dir, IndexingContext.INDEX_FILE + ".properties" );
         if ( properties != null )
         {
             OutputStream os = new BufferedOutputStream( new FileOutputStream( file ) );
@@ -487,6 +452,25 @@ public class DefaultIndexUpdater
         }
     }
 
+    private Properties downloadIndexProperties( final ResourceFetcher fetcher )
+        throws IOException
+    {
+        InputStream fis = fetcher.retrieve( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE );
+
+        try
+        {
+            Properties properties = new Properties();
+
+            properties.load( fis );
+
+            return properties;
+        }
+        finally
+        {
+            IOUtil.close( fis );
+        }
+    }
+
     public Date getTimestamp( final Properties properties, final String key )
     {
         String indexTimestamp = properties.getProperty( key );
@@ -580,21 +564,17 @@ public class DefaultIndexUpdater
     {
         protected final File dir;
 
-        private Properties properties;
+        protected Properties properties;
 
         protected IndexAdaptor( File dir )
         {
             this.dir = dir;
         }
 
-        public Properties getProperties()
-        {
-            if ( properties == null )
-            {
-                properties = loadIndexProperties( dir );
-            }
-            return properties;
-        }
+        public abstract Properties getProperties();
+
+        public abstract void storeProperties()
+            throws IOException;
 
         public abstract void addIndexChunk( ResourceFetcher source, String filename )
             throws IOException;
@@ -614,7 +594,7 @@ public class DefaultIndexUpdater
         public void commit()
             throws IOException
         {
-            storeIndexProperties( dir, properties );
+            storeProperties();
         }
     }
 
@@ -629,6 +609,21 @@ public class DefaultIndexUpdater
             this.updateRequest = updateRequest;
         }
 
+        public Properties getProperties()
+        {
+            if ( properties == null )
+            {
+                properties = loadIndexProperties( dir, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE );
+            }
+            return properties;
+        }
+
+        public void storeProperties()
+            throws IOException
+        {
+            storeIndexProperties( dir, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE, properties );
+        }
+
         public Date getTimestamp()
         {
             return updateRequest.getIndexingContext().getTimestamp();
@@ -645,6 +640,15 @@ public class DefaultIndexUpdater
         {
             return loadIndexDirectory( updateRequest, source, false, filename );
         }
+
+        public void commit()
+            throws IOException
+        {
+            super.commit();
+            
+            updateRequest.getIndexingContext().commit();
+        }
+
     }
 
     private class LocalCacheIndexAdaptor
@@ -664,6 +668,21 @@ public class DefaultIndexUpdater
             this.result = result;
         }
 
+        public Properties getProperties()
+        {
+            if ( properties == null )
+            {
+                properties = loadIndexProperties( dir, IndexingContext.INDEX_REMOTE_PROPERTIES_FILE );
+            }
+            return properties;
+        }
+
+        public void storeProperties()
+            throws IOException
+        {
+            storeIndexProperties( dir, IndexingContext.INDEX_REMOTE_PROPERTIES_FILE, properties );
+        }
+
         public Date getTimestamp()
         {
             Properties properties = getProperties();
@@ -778,11 +797,15 @@ public class DefaultIndexUpdater
                                       IndexAdaptor target )
         throws IOException
     {
-        Date targetTimestamp = target.getTimestamp();
-
         if ( !updateRequest.isForceFullUpdate() )
         {
             Properties localProperties = target.getProperties();
+            Date localTimestamp = null;
+
+            if ( localProperties != null )
+            {
+                localTimestamp = getTimestamp( localProperties, IndexingContext.INDEX_TIMESTAMP );
+            }
 
             // this will download and store properties in the target, so next run
             // target.getProperties() will retrieve it
@@ -812,11 +835,18 @@ public class DefaultIndexUpdater
                 updateTimestamp = getTimestamp( remoteProperties, IndexingContext.INDEX_LEGACY_TIMESTAMP );
             }
 
-            // if incremental cant be done for whatever reason, simply use old logic of
-            // checking the timestamp, if the same, nothing to do
-            if ( updateTimestamp != null && targetTimestamp != null && !updateTimestamp.after( targetTimestamp ) )
-            {
-                return null; // index is up to date
+            // fallback to timestamp comparison, but try with one coming from local properties, and if not possible (is
+            // null)
+            // fallback to context timestamp
+            if ( localTimestamp != null )
+            {
+                // if we have localTimestamp
+                // if incremental cant be done for whatever reason, simply use old logic of
+                // checking the timestamp, if the same, nothing to do
+                if ( updateTimestamp != null && localTimestamp != null && !updateTimestamp.after( localTimestamp ) )
+                {
+                    return null; // index is up to date
+                }
             }
         }
         else
@@ -827,7 +857,7 @@ public class DefaultIndexUpdater
 
         try
         {
-            Date timestamp = target.setIndexFile( source, IndexingContext.INDEX_FILE + ".gz" );
+            Date timestamp = target.setIndexFile( source, IndexingContext.INDEX_FILE_PREFIX + ".gz" );
             if ( source instanceof LocalIndexCacheFetcher )
             {
                 // local cache has inverse organization compared to remote indexes,
@@ -842,7 +872,7 @@ public class DefaultIndexUpdater
         catch ( IOException ex )
         {
             // try to look for legacy index transfer format
-            return target.setIndexFile( source, IndexingContext.INDEX_FILE + ".zip" );
+            return target.setIndexFile( source, IndexingContext.INDEX_FILE_PREFIX + ".zip" );
         }
     }
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdater.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdater.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdater.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdater.java Tue Dec 28 16:14:47 2010
@@ -19,10 +19,7 @@
 package org.apache.maven.index.updater;
 
 import java.io.IOException;
-import java.util.Date;
-import java.util.Properties;
 
-import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.packer.IndexPacker;
 
 /**
@@ -54,14 +51,9 @@ import org.apache.maven.index.packer.Ind
  */
 public interface IndexUpdater
 {
-    Properties fetchIndexProperties( IndexingContext context, ResourceFetcher fetcher )
-        throws IOException;
-
     /**
      * @return IndexUpdateResult
      */
     IndexUpdateResult fetchAndUpdateIndex( IndexUpdateRequest updateRequest )
         throws IOException;
-
-    Date getTimestamp( Properties properties, String key );
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/WagonHelper.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/WagonHelper.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/WagonHelper.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/WagonHelper.java Tue Dec 28 16:14:47 2010
@@ -19,8 +19,10 @@
 package org.apache.maven.index.updater;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
@@ -68,7 +70,6 @@ public class WagonHelper
     }
 
     public static class WagonFetcher
-        extends AbstractResourceFetcher
         implements ResourceFetcher
     {
         private final TransferListener listener;
@@ -157,6 +158,23 @@ public class WagonHelper
             }
         }
 
+        public InputStream retrieve( String name )
+            throws IOException, FileNotFoundException
+        {
+            final File target = File.createTempFile( name, "" );
+            retrieve( name, target );
+            return new FileInputStream( target )
+            {
+                @Override
+                public void close()
+                    throws IOException
+                {
+                    super.close();
+                    target.delete();
+                }
+            };
+        }
+
         public void retrieve( final String name, final File targetFile )
             throws IOException, FileNotFoundException
         {

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java Tue Dec 28 16:14:47 2010
@@ -1,5 +1,6 @@
 package org.apache.maven.index;
 
+import java.io.File;
 import java.util.Collections;
 
 import org.apache.maven.index.context.IndexingContext;
@@ -9,6 +10,8 @@ public class Nexus1911IncrementalMergedC
 {
     IndexingContext member;
 
+    File indexMergedDir;
+
     @Override
     protected void setUp()
         throws Exception
@@ -17,8 +20,10 @@ public class Nexus1911IncrementalMergedC
 
         member = context;
 
+        indexMergedDir = super.getDirectory( "index/nexus-1911-merged" );
+
         context =
-            indexer.addMergedIndexingContext( "merged", "merged", member.getRepository(), false,
+            indexer.addMergedIndexingContext( "merged", "merged", member.getRepository(), indexMergedDir, false,
                 Collections.singletonList( member ) );
     }
 
@@ -27,9 +32,9 @@ public class Nexus1911IncrementalMergedC
         throws Exception
     {
         indexer.removeIndexingContext( context, true );
-        
+
         context = member;
-        
+
         super.tearDown();
     }
 }

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java Tue Dec 28 16:14:47 2010
@@ -94,11 +94,11 @@ public class Nexus1911IncrementalTest
         Set<String> filenames = getFilenamesFromFiles( indexPackDir.listFiles() );
         Properties props = getPropertiesFromFiles( indexPackDir.listFiles() );
 
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".zip" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".properties" ) );
-        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE + ".1.gz" ) );
-        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE + ".2.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".properties" ) );
+        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
+        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
 
         Assert.assertNotNull( props );
 
@@ -123,11 +123,11 @@ public class Nexus1911IncrementalTest
         Set<String> filenames = getFilenamesFromFiles( indexPackDir.listFiles() );
         Properties props = getPropertiesFromFiles( indexPackDir.listFiles() );
 
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".zip" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".properties" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".1.gz" ) );
-        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE + ".2.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".properties" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
+        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
 
         Assert.assertNotNull( props );
 
@@ -153,12 +153,12 @@ public class Nexus1911IncrementalTest
         Set<String> filenames = getFilenamesFromFiles( indexPackDir.listFiles() );
         Properties props = getPropertiesFromFiles( indexPackDir.listFiles() );
 
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".zip" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".properties" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".1.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".2.gz" ) );
-        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE + ".3.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".properties" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
+        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
 
         Assert.assertNotNull( props );
 
@@ -185,12 +185,12 @@ public class Nexus1911IncrementalTest
         Set<String> filenames = getFilenamesFromFiles( indexPackDir.listFiles() );
         Properties props = getPropertiesFromFiles( indexPackDir.listFiles() );
 
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".zip" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".properties" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".1.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".2.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".3.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".properties" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
 
         Assert.assertNotNull( props );
 
@@ -219,13 +219,13 @@ public class Nexus1911IncrementalTest
         Set<String> filenames = getFilenamesFromFiles( indexPackDir.listFiles() );
         Properties props = getPropertiesFromFiles( indexPackDir.listFiles() );
 
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".zip" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".properties" ) );
-        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE + ".1.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".2.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".3.gz" ) );
-        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE + ".4.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".properties" ) );
+        Assert.assertFalse( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
+        Assert.assertTrue( filenames.contains( IndexingContext.INDEX_FILE_PREFIX + ".4.gz" ) );
 
         Assert.assertNotNull( props );
 
@@ -272,7 +272,7 @@ public class Nexus1911IncrementalTest
 
         for ( int i = 0; i < files.length; i++ )
         {
-            if ( ( IndexingContext.INDEX_FILE + ".properties" ).equalsIgnoreCase( files[i].getName() ) )
+            if ( ( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ).equalsIgnoreCase( files[i].getName() ) )
             {
                 propertyFile = files[i];
                 break;

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java Tue Dec 28 16:14:47 2010
@@ -240,8 +240,10 @@ public class NexusIndexerTest
     {
         NexusIndexer indexer = prepare();
 
+        File indexMergedDir = super.getDirectory( "index/testMerged" );
+
         IndexingContext mergedContext =
-            new MergedIndexingContext( "test", "merged", context.getRepository(), true,
+            new MergedIndexingContext( "test", "merged", context.getRepository(), indexMergedDir, true,
                 new StaticContextMemberProvider( Collections.singletonList( context ) ) );
 
         performQueryCreatorNGSearch( indexer, mergedContext );

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java Tue Dec 28 16:14:47 2010
@@ -293,11 +293,16 @@ public class DefaultIndexUpdaterTest
 
         final IndexingContext tempContext = mockery.mock( IndexingContext.class );
 
+        final Properties localProps = new Properties();
+        localProps.setProperty( IndexingContext.INDEX_CHUNK_COUNTER, "1" );
+        localProps.setProperty( IndexingContext.INDEX_CHAIN_ID, "someid" );
+        localProps.setProperty( IndexingContext.INDEX_TIMESTAMP, "20081125010000.000 -0600" );
+
         mockery.checking( new Expectations()
         {
             {
                 allowing( tempContext ).getIndexDirectoryFile();
-                will( new ReturnValueAction( testBasedir ) );
+                will( new IndexDirectoryFileAction( localProps, testBasedir ) );
 
                 allowing( tempContext ).getTimestamp();
                 will( returnValue( contextTimestamp ) );
@@ -305,6 +310,8 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getId();
                 will( returnValue( repositoryId ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getIndexUpdateUrl();
                 will( returnValue( indexUrl ) );
 
@@ -314,7 +321,7 @@ public class DefaultIndexUpdaterTest
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -369,13 +376,17 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexUpdateUrl();
                 will( returnValue( indexUrl ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getIndexCreators();
                 will( returnValue( DEFAULT_CREATORS ) );
 
+                allowing( tempContext ).commit();
+
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -391,7 +402,7 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexDirectoryFile();
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
                 will( returnValue( newInputStream( "/index-updater/server-root/nexus-maven-repository-index.gz" ) ) );
 
                 oneOf( tempContext ).replace( with( any( Directory.class ) ) );
@@ -437,13 +448,15 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexUpdateUrl();
                 will( returnValue( indexUrl ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getIndexCreators();
                 will( returnValue( DEFAULT_CREATORS ) );
 
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -465,10 +478,10 @@ public class DefaultIndexUpdaterTest
                 will( new IndexDirectoryFileAction( localProps, testBasedir ) );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".2.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
                 will( returnValue( newInputStream( "/index-updater/server-root/nexus-maven-repository-index.gz" ) ) );
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".3.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
                 will( returnValue( newInputStream( "/index-updater/server-root/nexus-maven-repository-index.gz" ) ) );
                 // could create index archive there and verify that it is merged correctly
 
@@ -516,13 +529,15 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexUpdateUrl();
                 will( returnValue( indexUrl ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getIndexCreators();
                 will( returnValue( DEFAULT_CREATORS ) );
 
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -541,14 +556,14 @@ public class DefaultIndexUpdaterTest
                 } );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
                 will( returnValue( newInputStream( "/index-updater/server-root/nexus-maven-repository-index.gz" ) ) );
                 // could create index archive there and verify that it is merged correctly
 
                 oneOf( tempContext ).replace( with( any( Directory.class ) ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".2.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
 
                 never( tempContext ).merge( with( any( Directory.class ) ) );
 
@@ -596,10 +611,12 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexCreators();
                 will( returnValue( DEFAULT_CREATORS ) );
 
+                allowing( tempContext ).commit();
+
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -621,17 +638,17 @@ public class DefaultIndexUpdaterTest
                 will( new IndexDirectoryFileAction( localProps, testBasedir ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
                 // could create index archive there and verify that it is merged correctly
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".1.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".2.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".3.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
 
                 never( tempContext ).merge( with( any( Directory.class ) ) );
 
@@ -677,13 +694,15 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getIndexUpdateUrl();
                 will( returnValue( indexUrl ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getIndexCreators();
                 will( returnValue( DEFAULT_CREATORS ) );
 
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -704,15 +723,15 @@ public class DefaultIndexUpdaterTest
                 never( tempContext ).getIndexDirectoryFile();
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".1.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".1.gz" ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".2.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".2.gz" ) );
 
                 never( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".3.gz" ) );
+                    with( IndexingContext.INDEX_FILE_PREFIX + ".3.gz" ) );
 
-                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE + ".gz" ) );
+                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
                 will( returnValue( newInputStream( "/index-updater/server-root/nexus-maven-repository-index.gz" ) ) );
 
                 never( tempContext ).merge( with( any( Directory.class ) ) );
@@ -757,6 +776,8 @@ public class DefaultIndexUpdaterTest
                 allowing( tempContext ).getTimestamp();
                 will( returnValue( contextTimestamp ) );
 
+                allowing( tempContext ).commit();
+
                 allowing( tempContext ).getId();
                 will( returnValue( repositoryId ) );
 
@@ -769,7 +790,7 @@ public class DefaultIndexUpdaterTest
                 oneOf( mockFetcher ).connect( repositoryId, indexUrl );
 
                 oneOf( mockFetcher ).retrieve( //
-                    with( IndexingContext.INDEX_FILE + ".properties" ) );
+                    with( IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ) );
                 will( new PropertiesAction()
                 {
                     @Override
@@ -784,11 +805,11 @@ public class DefaultIndexUpdaterTest
 
                 never( tempContext ).getIndexDirectoryFile();
 
-                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE + ".gz" ) );
+                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE_PREFIX + ".gz" ) );
 
                 will( throwException( new IOException() ) );
 
-                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE + ".zip" ) );
+                oneOf( mockFetcher ).retrieve( with( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) );
 
                 will( returnValue( newInputStream( "/index-updater/server-root/legacy/nexus-maven-repository-index.zip" ) ) );
 
@@ -854,7 +875,7 @@ public class DefaultIndexUpdaterTest
         {
             basedir.mkdirs();
 
-            this.file = new File( basedir, IndexingContext.INDEX_FILE + ".properties" );
+            this.file = new File( basedir, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE );
 
             FileOutputStream fos = null;
             try

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java?rev=1053381&r1=1053380&r2=1053381&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java Tue Dec 28 16:14:47 2010
@@ -252,8 +252,8 @@ public class LocalIndexCacheTest
             public InputStream retrieve( String name )
                 throws IOException, java.io.FileNotFoundException
             {
-                if ( name.equals( IndexingContext.INDEX_FILE + ".gz" )
-                    || name.equals( IndexingContext.INDEX_FILE + ".zip" ) )
+                if ( name.equals( IndexingContext.INDEX_FILE_PREFIX + ".gz" )
+                    || name.equals( IndexingContext.INDEX_FILE_PREFIX + ".zip" ) )
                 {
                     throw new IOException();
                 }



Mime
View raw message