]> source.dussan.org Git - archiva.git/commitdiff
[MRM-749]
authorMaria Odea B. Ching <oching@apache.org>
Thu, 22 Jan 2009 11:03:38 +0000 (11:03 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Thu, 22 Jan 2009 11:03:38 +0000 (11:03 +0000)
o re-packaged TriggerScanCompleteClosure
o invoke TriggerScanCompleteClosure at the end of the scan

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-nexus-indexer@736609 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java [deleted file]

index ce8f6b1c50183249c48812994d9348a8f8630661..7176878a4bacd608b88eb76fdbc4a24e939facd2 100644 (file)
@@ -91,7 +91,7 @@ public class NexusIndexerConsumer
 
     public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
         throws ConsumerException
-    {
+    {   
         this.repository = repository;
         managedRepository = new File( repository.getLocation() );
         File indexDirectory = new File( managedRepository, ".indexer" );
@@ -125,14 +125,14 @@ public class NexusIndexerConsumer
         throws ConsumerException
     {
         File artifactFile = new File( managedRepository, path );
-    
+        
         ArtifactContext artifactContext = artifactContextProducer.getArtifactContext( context, artifactFile );
         if ( artifactContext != null )
         {
             try
             {
-                indexer.artifactDiscovered( artifactContext, context );
-             
+                //indexer.artifactDiscovered( artifactContext, context );
+                
                 indexerEngine.index( context, artifactContext );
             }
             catch ( IOException e )
@@ -143,12 +143,13 @@ public class NexusIndexerConsumer
     }
 
     public void completeScan()
-    {
+    {   
         final File indexLocation = new File( managedRepository, ".index" );
         try
         {
-            indexPacker.packIndex( context, indexLocation );
             indexerEngine.endIndexing( context );
+            
+            indexPacker.packIndex( context, indexLocation );
         }
         catch ( IOException e )
         {
index 4adb402f676ce25dec9a8c1fe578faa97fed2676..94f43f682d3335800523da29ec952adeb2ec8aa2 100644 (file)
@@ -120,7 +120,13 @@ public class NexusIndexerConsumerTest
         ArtifactInfo artifactInfo = (ArtifactInfo) results.iterator().next();
         assertEquals( "org.apache.archiva", artifactInfo.groupId );
         assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
-        assertEquals( "test-repo", artifactInfo.repository );        
+        assertEquals( "test-repo", artifactInfo.repository );   
+    }
+    
+    public void testIndexerArtifactAlreadyIndexed()
+        throws Exception
+    {
+    
     }
     
     /*public void testIndexerIndexPom()
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java
new file mode 100644 (file)
index 0000000..52a9ca1
--- /dev/null
@@ -0,0 +1,52 @@
+package org.apache.archiva.repository.scanner.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Closure;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TriggerScanCompletedClosure
+ */
+public class TriggerScanCompletedClosure
+    implements Closure
+{
+    private Logger log = LoggerFactory.getLogger( TriggerScanCompletedClosure.class );
+
+    private final ManagedRepositoryConfiguration repository;
+
+    public TriggerScanCompletedClosure( ManagedRepositoryConfiguration repository )
+    {
+        this.repository = repository;
+    }
+
+    public void execute( Object input )
+    {
+        if ( input instanceof RepositoryContentConsumer )
+        {
+            RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
+            consumer.completeScan();
+            log.info( "Consumer [" + consumer.getId() + "] completed for repository [" + repository.getId() + "]" );
+        }
+    }
+}
index e81148620813240f51aeff32c9def6022611c1cb..6f35e81f35c5f375bdb583d4433b8cda2cc48218 100644 (file)
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
 import org.apache.commons.collections.Closure;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.functors.IfClosure;
@@ -38,7 +39,6 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
 import org.apache.maven.archiva.repository.scanner.functors.ConsumerWantsFilePredicate;
 import org.apache.maven.archiva.repository.scanner.functors.TriggerBeginScanClosure;
-import org.apache.maven.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
index 1ae3e796061e61a28a8edc3ef20deccce0d5b174..e8d86d90c6870dfc1bb96f899094bb71368f6e5e 100644 (file)
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
 import org.apache.commons.collections.Closure;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.functors.IfClosure;
@@ -34,7 +35,6 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
 import org.apache.maven.archiva.repository.scanner.functors.ConsumerWantsFilePredicate;
 import org.apache.maven.archiva.repository.scanner.functors.TriggerBeginScanClosure;
-import org.apache.maven.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
 import org.codehaus.plexus.util.DirectoryWalkListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -91,11 +91,6 @@ public class RepositoryScannerInstance
         {
             consumerWantsFile.setCaseSensitive( false );
         }
-
-        TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure(repository);
-
-        CollectionUtils.forAllDo(knownConsumers, scanCompletedClosure);
-        CollectionUtils.forAllDo(invalidConsumerList, scanCompletedClosure);
     }
 
     public RepositoryScannerInstance( ManagedRepositoryConfiguration repository,
@@ -150,6 +145,11 @@ public class RepositoryScannerInstance
 
     public void directoryWalkFinished()
     {
+        TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure(repository);
+        
+        CollectionUtils.forAllDo( knownConsumers, scanCompletedClosure );
+        CollectionUtils.forAllDo( invalidConsumers, scanCompletedClosure );
+        
         log.info( "Walk Finished: [" + this.repository.getId() + "] " + this.repository.getLocation() );
         stats.triggerFinished();
     }
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerScanCompletedClosure.java
deleted file mode 100644 (file)
index 85548b5..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  Copyright 2008 jdumay.
- * 
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  under the License.
- */
-
-package org.apache.maven.archiva.repository.scanner.functors;
-
-import org.apache.commons.collections.Closure;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TriggerScanCompletedClosure implements Closure
-{
-    private Logger log = LoggerFactory.getLogger( TriggerScanCompletedClosure.class );
-
-    private final ManagedRepositoryConfiguration repository;
-
-    public TriggerScanCompletedClosure(ManagedRepositoryConfiguration repository)
-    {
-        this.repository = repository;
-    }
-
-    public void execute(Object input)
-    {
-        if ( input instanceof RepositoryContentConsumer )
-        {
-            RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
-            consumer.completeScan();
-            log.info( "Consumer [" + consumer.getId() + "] completed for repository [" + repository.getId() + "]");
-        }
-    }
-}