mirror of https://github.com/apache/archiva.git
[MRM-749]
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
This commit is contained in:
parent
047e989d7a
commit
352b1d8a65
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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() + "]" );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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() + "]");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue