Switching to apache commons collections4

This commit is contained in:
Martin Stockhammer 2018-04-01 17:21:48 +02:00
parent b3335cf6e5
commit 98236b99cb
37 changed files with 75 additions and 65 deletions

View File

@ -120,6 +120,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-policies</artifactId>

View File

@ -38,9 +38,9 @@ import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry;
import org.apache.archiva.redback.components.springutils.ComponentContainer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;

View File

@ -26,8 +26,8 @@ import org.apache.archiva.redback.components.registry.Registry;
import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.configuration.CombinedConfiguration;
import org.apache.tools.ant.types.selectors.SelectorUtils;
import org.springframework.stereotype.Service;

View File

@ -20,7 +20,7 @@ package org.apache.archiva.configuration.functors;
*/
import org.apache.archiva.configuration.FileType;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.lang.StringUtils;
/**

View File

@ -20,7 +20,7 @@ package org.apache.archiva.configuration.functors;
*/
import org.apache.archiva.configuration.FileType;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import java.util.HashMap;
import java.util.Map;

View File

@ -20,7 +20,7 @@ package org.apache.archiva.configuration.functors;
*/
import org.apache.archiva.configuration.NetworkProxyConfiguration;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.lang.StringUtils;
/**

View File

@ -20,7 +20,7 @@ package org.apache.archiva.configuration.functors;
*/
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.lang.StringUtils;
/**

View File

@ -42,8 +42,8 @@
<artifactId>archiva-repository-layer</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>

View File

@ -23,7 +23,7 @@ import org.apache.archiva.common.utils.BaseFile;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.tools.ant.types.selectors.SelectorUtils;

View File

@ -68,6 +68,7 @@ public abstract class AbstractArtifactConsumerTest
}
@SuppressWarnings( "deprecation" )
@Test
public void testConsumption()
{
@ -81,6 +82,7 @@ public abstract class AbstractArtifactConsumerTest
assertFalse( predicate.evaluate( consumer ) );
}
@SuppressWarnings( "deprecation" )
@Test
public void testConsumptionOfOtherMetadata()
{

View File

@ -108,6 +108,7 @@ public class RepositoryPurgeConsumerTest
fileType.removePattern( "**/*.xml" );
}
@SuppressWarnings( "deprecation" )
private void assertNotConsumed( String path )
throws Exception
{

View File

@ -34,8 +34,8 @@
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>

View File

@ -94,8 +94,8 @@
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>

View File

@ -65,7 +65,7 @@ import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;

View File

@ -34,8 +34,8 @@
<artifactId>archiva-repository-layer</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>

View File

@ -19,7 +19,7 @@ package org.apache.archiva.admin.model.proxyconnector;
*/
import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.lang.StringUtils;
/**

View File

@ -20,7 +20,7 @@ package org.apache.archiva.admin.repository.admin;
*/
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import java.util.HashMap;
import java.util.Map;

View File

@ -29,7 +29,7 @@ import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

View File

@ -43,7 +43,7 @@ import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.time.DateUtils;

View File

@ -24,7 +24,7 @@ import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.model.Plugin;
import org.apache.archiva.xml.XMLException;
import org.apache.archiva.xml.XMLWriter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;

View File

@ -25,7 +25,7 @@ import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

View File

@ -32,9 +32,10 @@ import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
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;
import org.apache.commons.collections4.Closure;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.collections4.functors.IfClosure;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@ -296,8 +297,8 @@ public class RepositoryContentConsumers
}
List<InvalidRepositoryContentConsumer> selectedInvalidConsumers = getSelectedInvalidConsumers();
CollectionUtils.forAllDo( selectedKnownConsumers, triggerBeginScan );
CollectionUtils.forAllDo( selectedInvalidConsumers, triggerBeginScan );
IterableUtils.forEach( selectedKnownConsumers, triggerBeginScan );
IterableUtils.forEach( 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"
@ -311,25 +312,25 @@ public class RepositoryContentConsumers
closure.setBasefile( baseFile );
closure.setExecuteOnEntireRepo( false );
Closure processIfWanted = IfClosure.getInstance( predicate, closure );
Closure processIfWanted = IfClosure.ifClosure( predicate, closure );
CollectionUtils.forAllDo( selectedKnownConsumers, processIfWanted );
IterableUtils.forEach( selectedKnownConsumers, processIfWanted );
if ( predicate.getWantedFileCount() <= 0 )
{
// Nothing known processed this file. It is invalid!
CollectionUtils.forAllDo( selectedInvalidConsumers, closure );
IterableUtils.forEach( selectedInvalidConsumers, closure );
}
TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure( repository, false );
CollectionUtils.forAllDo( selectedKnownConsumers, scanCompletedClosure );
IterableUtils.forEach( selectedKnownConsumers, scanCompletedClosure );
}
finally
{
/* TODO: This is never called by the repository scanner instance, so not calling here either - but it probably should be?
CollectionUtils.forAllDo( availableKnownConsumers, triggerCompleteScan );
CollectionUtils.forAllDo( availableInvalidConsumers, triggerCompleteScan );
IterableUtils.forEach( availableKnownConsumers, triggerCompleteScan );
IterableUtils.forEach( availableInvalidConsumers, triggerCompleteScan );
*/
releaseSelectedKnownConsumers( selectedKnownConsumers );
}

View File

@ -20,7 +20,7 @@ package org.apache.archiva.repository.scanner;
*/
import org.apache.archiva.repository.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import javax.xml.bind.annotation.XmlRootElement;
import java.text.SimpleDateFormat;

View File

@ -28,9 +28,10 @@ import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
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;
import org.apache.commons.collections4.Closure;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.collections4.functors.IfClosure;
import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -120,8 +121,8 @@ public class RepositoryScannerInstance
Closure triggerBeginScan =
new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ), true );
CollectionUtils.forAllDo( knownConsumerList, triggerBeginScan );
CollectionUtils.forAllDo( invalidConsumerList, triggerBeginScan );
IterableUtils.forEach( knownConsumerList, triggerBeginScan );
IterableUtils.forEach( invalidConsumerList, triggerBeginScan );
if ( SystemUtils.IS_OS_WINDOWS )
{
@ -239,13 +240,13 @@ public class RepositoryScannerInstance
consumerProcessFile.setBasefile( basefile );
consumerWantsFile.setBasefile( basefile );
Closure processIfWanted = IfClosure.getInstance( consumerWantsFile, consumerProcessFile );
CollectionUtils.forAllDo( this.knownConsumers, processIfWanted );
Closure processIfWanted = IfClosure.ifClosure( consumerWantsFile, consumerProcessFile );
IterableUtils.forEach( this.knownConsumers, processIfWanted );
if ( consumerWantsFile.getWantedFileCount() <= 0 )
{
// Nothing known processed this file. It is invalid!
CollectionUtils.forAllDo( this.invalidConsumers, consumerProcessFile );
IterableUtils.forEach( this.invalidConsumers, consumerProcessFile );
}
}
@ -272,8 +273,8 @@ public class RepositoryScannerInstance
private void finishWalk() {
this.isRunning = false;
TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure( repository, true );
CollectionUtils.forAllDo( knownConsumers, scanCompletedClosure );
CollectionUtils.forAllDo( invalidConsumers, scanCompletedClosure );
IterableUtils.forEach( knownConsumers, scanCompletedClosure );
IterableUtils.forEach( invalidConsumers, scanCompletedClosure );
stats.setConsumerTimings( consumerTimings );
stats.setConsumerCounts( consumerCounts );

View File

@ -21,7 +21,7 @@ package org.apache.archiva.repository.scanner.functors;
import org.apache.archiva.common.utils.BaseFile;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.repository.scanner.functors;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -21,7 +21,7 @@ package org.apache.archiva.repository.scanner.functors;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -34,8 +34,8 @@
<artifactId>archiva-common</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>

View File

@ -19,7 +19,7 @@ package org.apache.archiva.xml;
* under the License.
*/
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import org.dom4j.Element;
import java.util.ArrayList;

View File

@ -157,7 +157,7 @@ public class ArchivaIndexingTaskExecutorTest
assertTrue( Files.exists(basePath.resolve( ".indexer" )) );
assertTrue( Files.exists(basePath.resolve(".index" )) );
assertEquals( 1, response.getTotalHits() );
assertEquals( 1, response.getTotalHitsCount());
Set<ArtifactInfo> results = response.getResults();

View File

@ -31,7 +31,8 @@ import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.services.utils.AddAdminRepoConsumerClosure;
import org.apache.archiva.rest.services.utils.AdminRepositoryConsumerComparator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
@ -412,7 +413,7 @@ public class DefaultArchivaAdministrationService
{
AddAdminRepoConsumerClosure addAdminRepoConsumer =
new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
CollectionUtils.forAllDo( repoConsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
IterableUtils.forEach( repoConsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
List<AdminRepositoryConsumer> knownContentConsumers = addAdminRepoConsumer.getList();
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
return knownContentConsumers;
@ -431,7 +432,7 @@ public class DefaultArchivaAdministrationService
{
AddAdminRepoConsumerClosure addAdminRepoConsumer =
new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
CollectionUtils.forAllDo( repoConsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
IterableUtils.forEach( repoConsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
List<AdminRepositoryConsumer> invalidContentConsumers = addAdminRepoConsumer.getList();
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
return invalidContentConsumers;

View File

@ -58,7 +58,7 @@ import org.apache.archiva.rest.api.services.BrowseService;
import org.apache.archiva.rest.services.utils.ArtifactContentEntryComparator;
import org.apache.archiva.security.ArchivaSecurityException;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

View File

@ -38,7 +38,7 @@ import org.apache.archiva.rest.api.model.SearchRequest;
import org.apache.archiva.rest.api.model.StringList;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.SearchService;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

View File

@ -21,7 +21,7 @@ package org.apache.archiva.rest.services.utils;
import org.apache.archiva.consumers.RepositoryContentConsumer;
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections4.Closure;
import java.util.ArrayList;
import java.util.List;

View File

@ -32,7 +32,7 @@ import org.apache.archiva.redback.role.RoleManagerException;
import org.apache.archiva.redback.system.check.EnvironmentCheck;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.StopWatch;
import org.slf4j.Logger;

View File

@ -37,7 +37,7 @@ import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.redback.components.registry.Registry;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;

View File

@ -49,7 +49,7 @@
<properties>
<commons-codec.version>1.6</commons-codec.version>
<commons-collections.version>3.2.1</commons-collections.version>
<commons-collections.version>4.1</commons-collections.version>
<commons-fileupload.version>1.2.2</commons-fileupload.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
@ -699,8 +699,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<dependency>