*/
private List<InvalidRepositoryContentConsumer> availableInvalidConsumers;
+ private List<KnownRepositoryContentConsumer> selectedKnownConsumers;
+
+ private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
+
/**
* <p>
* Get the list of Ids associated with those {@link KnownRepositoryContentConsumer} that have
{
Map<String, KnownRepositoryContentConsumer> consumerMap = new HashMap<String, KnownRepositoryContentConsumer>();
- List<String> knownSelected = getSelectedKnownConsumerIds();
-
- for ( KnownRepositoryContentConsumer consumer : availableKnownConsumers )
+ for ( KnownRepositoryContentConsumer consumer : getSelectedKnownConsumers() )
{
- if ( knownSelected.contains( consumer.getId() ) || consumer.isPermanent() )
- {
- consumerMap.put( consumer.getId(), consumer );
- }
+ consumerMap.put( consumer.getId(), consumer );
}
return consumerMap;
{
Map<String, InvalidRepositoryContentConsumer> consumerMap = new HashMap<String, InvalidRepositoryContentConsumer>();
- List<String> invalidSelected = getSelectedInvalidConsumerIds();
-
- for ( InvalidRepositoryContentConsumer consumer : availableInvalidConsumers )
+ for ( InvalidRepositoryContentConsumer consumer : getSelectedInvalidConsumers() )
{
- if ( invalidSelected.contains( consumer.getId() ) || consumer.isPermanent() )
- {
- consumerMap.put( consumer.getId(), consumer );
- }
+ consumerMap.put( consumer.getId(), consumer );
}
return consumerMap;
* @return the list of {@link KnownRepositoryContentConsumer} that have been selected
* by the active configuration.
*/
- public List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
+ public synchronized List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
{
- List<KnownRepositoryContentConsumer> ret = new ArrayList<KnownRepositoryContentConsumer>();
+ if ( selectedKnownConsumers == null )
+ {
+ List<KnownRepositoryContentConsumer> ret = new ArrayList<KnownRepositoryContentConsumer>();
- List<String> knownSelected = getSelectedKnownConsumerIds();
+ List<String> knownSelected = getSelectedKnownConsumerIds();
- for ( KnownRepositoryContentConsumer consumer : availableKnownConsumers )
- {
- if ( knownSelected.contains( consumer.getId() ) || consumer.isPermanent() )
+ for ( KnownRepositoryContentConsumer consumer : availableKnownConsumers )
{
- ret.add( consumer );
+ if ( knownSelected.contains( consumer.getId() ) || consumer.isPermanent() )
+ {
+ ret.add( consumer );
+ }
}
+ this.selectedKnownConsumers = ret;
}
-
- return ret;
+ return selectedKnownConsumers;
}
/**
* @return the list of {@link InvalidRepositoryContentConsumer} that have been selected
* by the active configuration.
*/
- public List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
+ public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
{
- List<InvalidRepositoryContentConsumer> ret = new ArrayList<InvalidRepositoryContentConsumer>();
+ if ( selectedInvalidConsumers == null )
+ {
+ List<InvalidRepositoryContentConsumer> ret = new ArrayList<InvalidRepositoryContentConsumer>();
- List<String> invalidSelected = getSelectedInvalidConsumerIds();
+ List<String> invalidSelected = getSelectedInvalidConsumerIds();
- for ( InvalidRepositoryContentConsumer consumer : availableInvalidConsumers )
- {
- if ( invalidSelected.contains( consumer.getId() ) || consumer.isPermanent() )
+ for ( InvalidRepositoryContentConsumer consumer : availableInvalidConsumers )
{
- ret.add( consumer );
+ if ( invalidSelected.contains( consumer.getId() ) || consumer.isPermanent() )
+ {
+ ret.add( consumer );
+ }
}
+ selectedInvalidConsumers = ret;
}
-
- return ret;
+ return selectedInvalidConsumers;
}
/**
{
Closure triggerBeginScan = new TriggerBeginScanClosure( repository, getLogger() );
- CollectionUtils.forAllDo( availableKnownConsumers, triggerBeginScan );
- CollectionUtils.forAllDo( availableInvalidConsumers, triggerBeginScan );
+ List<KnownRepositoryContentConsumer> selectedKnownConsumers = getSelectedKnownConsumers();
+ List<InvalidRepositoryContentConsumer> selectedInvalidConsumers = getSelectedInvalidConsumers();
+ CollectionUtils.forAllDo( selectedKnownConsumers, triggerBeginScan );
+ CollectionUtils.forAllDo( selectedInvalidConsumers, triggerBeginScan );
// yuck. In case you can't read this, it says
// "process the file if the consumer has it in the includes list, and not in the excludes list"
predicate.setCaseSensitive( false );
Closure processIfWanted = IfClosure.getInstance( predicate, closure );
- CollectionUtils.forAllDo( availableKnownConsumers, processIfWanted );
+ CollectionUtils.forAllDo( selectedKnownConsumers, processIfWanted );
if ( predicate.getWantedFileCount() <= 0 )
{
// Nothing known processed this file. It is invalid!
- CollectionUtils.forAllDo( availableInvalidConsumers, closure );
+ CollectionUtils.forAllDo( selectedInvalidConsumers, closure );
}
}
finally
}
}
+ public void setSelectedKnownConsumers( List<KnownRepositoryContentConsumer> selectedKnownConsumers )
+ {
+ this.selectedKnownConsumers = selectedKnownConsumers;
+ }
+
+ public void setSelectedInvalidConsumers( List<InvalidRepositoryContentConsumer> selectedInvalidConsumers )
+ {
+ this.selectedInvalidConsumers = selectedInvalidConsumers;
+ }
}
{
MockControl knownControl = MockControl.createNiceControl( KnownRepositoryContentConsumer.class );
RepositoryContentConsumers consumers = lookupRepositoryConsumers();
- KnownRepositoryContentConsumer knownConsumer = (KnownRepositoryContentConsumer) knownControl.getMock();
- consumers.setAvailableKnownConsumers( Collections.singletonList( knownConsumer ) );
+ KnownRepositoryContentConsumer selectedKnownConsumer = (KnownRepositoryContentConsumer) knownControl.getMock();
+ KnownRepositoryContentConsumer unselectedKnownConsumer =
+ (KnownRepositoryContentConsumer) MockControl.createNiceControl(
+ KnownRepositoryContentConsumer.class ).getMock();
+ consumers.setAvailableKnownConsumers( Arrays.asList( selectedKnownConsumer, unselectedKnownConsumer ) );
+ consumers.setSelectedKnownConsumers( Collections.singletonList( selectedKnownConsumer ) );
MockControl invalidControl = MockControl.createControl( InvalidRepositoryContentConsumer.class );
- InvalidRepositoryContentConsumer invalidConsumer = (InvalidRepositoryContentConsumer) invalidControl.getMock();
- consumers.setAvailableInvalidConsumers( Collections.singletonList( invalidConsumer ) );
+ InvalidRepositoryContentConsumer selectedInvalidConsumer =
+ (InvalidRepositoryContentConsumer) invalidControl.getMock();
+ InvalidRepositoryContentConsumer unselectedInvalidConsumer =
+ (InvalidRepositoryContentConsumer) MockControl.createControl(
+ InvalidRepositoryContentConsumer.class ).getMock();
+ consumers.setAvailableInvalidConsumers( Arrays.asList( selectedInvalidConsumer, unselectedInvalidConsumer ) );
+ consumers.setSelectedInvalidConsumers( Collections.singletonList( selectedInvalidConsumer ) );
ManagedRepositoryConfiguration repo = createRepository( "id", "name", getTestFile( "target/test-repo" ) );
File testFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
- knownConsumer.beginScan( repo );
- knownConsumer.getExcludes();
+ selectedKnownConsumer.beginScan( repo );
+ selectedKnownConsumer.getExcludes();
knownControl.setReturnValue( Collections.EMPTY_LIST );
- knownConsumer.getIncludes();
+ selectedKnownConsumer.getIncludes();
knownControl.setReturnValue( Collections.singletonList( "**/*.txt" ) );
- knownConsumer.processFile( _OS( "path/to/test-file.txt" ) );
+ selectedKnownConsumer.processFile( _OS( "path/to/test-file.txt" ) );
// knownConsumer.completeScan();
knownControl.replay();
- invalidConsumer.beginScan( repo );
+ selectedInvalidConsumer.beginScan( repo );
// invalidConsumer.completeScan();
invalidControl.replay();
File notIncludedTestFile = getTestFile( "target/test-repo/path/to/test-file.xml" );
- knownConsumer.beginScan( repo );
- knownConsumer.getExcludes();
+ selectedKnownConsumer.beginScan( repo );
+ selectedKnownConsumer.getExcludes();
knownControl.setReturnValue( Collections.EMPTY_LIST );
- knownConsumer.getIncludes();
+ selectedKnownConsumer.getIncludes();
knownControl.setReturnValue( Collections.singletonList( "**/*.txt" ) );
// knownConsumer.completeScan();
knownControl.replay();
- invalidConsumer.beginScan( repo );
- invalidConsumer.processFile( _OS( "path/to/test-file.xml" ) );
- invalidConsumer.getId();
+ selectedInvalidConsumer.beginScan( repo );
+ selectedInvalidConsumer.processFile( _OS( "path/to/test-file.xml" ) );
+ selectedInvalidConsumer.getId();
invalidControl.setReturnValue( "invalid" );
// invalidConsumer.completeScan();
invalidControl.replay();
File excludedTestFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
- knownConsumer.beginScan( repo );
- knownConsumer.getExcludes();
+ selectedKnownConsumer.beginScan( repo );
+ selectedKnownConsumer.getExcludes();
knownControl.setReturnValue( Collections.singletonList( "**/test-file.txt" ) );
// knownConsumer.completeScan();
knownControl.replay();
- invalidConsumer.beginScan( repo );
- invalidConsumer.processFile( _OS( "path/to/test-file.txt" ) );
- invalidConsumer.getId();
+ selectedInvalidConsumer.beginScan( repo );
+ selectedInvalidConsumer.processFile( _OS( "path/to/test-file.txt" ) );
+ selectedInvalidConsumer.getId();
invalidControl.setReturnValue( "invalid" );
// invalidConsumer.completeScan();
invalidControl.replay();