From 76a1d2429fd6a08b93e0b3f14644dee44b24b3e5 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 17 Mar 2009 16:18:51 +0000 Subject: [PATCH] warnings in scheduled and security modules git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755300 13f79535-47bb-0310-9956-ffa450edef68 --- .../TestDatabaseCleanupConsumer.java | 2 +- .../TestDatabaseUnprocessedConsumer.java | 4 +-- ...ArchivaDatabaseUpdateTaskExecutorTest.java | 31 ++++++++---------- ...ivaRepositoryScanningTaskExecutorTest.java | 32 +++++++++---------- .../security/DefaultUserRepositories.java | 12 ++----- .../archiva/security/SecurityStartup.java | 5 --- 6 files changed, 35 insertions(+), 51 deletions(-) diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java index 3b7781a8c..d8ab64a4e 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java @@ -56,7 +56,7 @@ public class TestDatabaseCleanupConsumer countComplete++; } - public List getIncludedTypes() + public List getIncludedTypes() { return null; } diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java index 6e4a6c8d8..6f3807c07 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java @@ -63,9 +63,9 @@ public class TestDatabaseUnprocessedConsumer countComplete++; } - public List getIncludedTypes() + public List getIncludedTypes() { - List types = new ArrayList(); + List types = new ArrayList(); types.add( "pom" ); types.add( "jar" ); return types; diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java index ac7692486..677c95062 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java @@ -19,6 +19,16 @@ package org.apache.maven.archiva.scheduled.executors; * under the License. */ +import java.io.File; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; @@ -31,17 +41,6 @@ import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.codehaus.plexus.taskqueue.execution.TaskExecutor; import org.jpox.SchemaTool; -import java.io.File; -import java.net.URL; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; - /** * ArchivaDatabaseUpdateTaskExecutorTest * @@ -102,10 +101,8 @@ public class ArchivaDatabaseUpdateTaskExecutorTest Properties properties = jdoFactory.getProperties(); - for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry entry : properties.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); } @@ -160,12 +157,12 @@ public class ArchivaDatabaseUpdateTaskExecutorTest assertNotNull( artifact ); // Test for artifact existance. - List artifactList = adao.queryArtifacts( null ); + List artifactList = adao.queryArtifacts( null ); assertNotNull( "Artifact list should not be null.", artifactList ); assertEquals( "Artifact list size", 1, artifactList.size() ); // Test for unprocessed artifacts. - List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList ); assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() ); @@ -182,7 +179,7 @@ public class ArchivaDatabaseUpdateTaskExecutorTest assertEquals( "Artifact list size", 1, artifactList.size() ); // Test for processed artifacts. - List processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) ); + List processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) ); assertNotNull( "Processed Results should not be null.", processedResultList ); assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() ); } diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java index 88b7f69f5..b350982f7 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java @@ -19,21 +19,8 @@ package org.apache.maven.archiva.scheduled.executors; * under the License. */ -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; -import org.codehaus.plexus.jdo.JdoFactory; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.codehaus.plexus.taskqueue.execution.TaskExecutor; -import org.jpox.SchemaTool; - import java.io.File; import java.net.URL; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -41,6 +28,19 @@ import java.util.Properties; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.ArtifactDAO; +import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; +import org.apache.maven.archiva.model.ArchivaArtifact; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; +import org.codehaus.plexus.jdo.JdoFactory; +import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.jpox.SchemaTool; + /** * ArchivaRepositoryScanningTaskExecutorTest * @@ -101,10 +101,8 @@ public class ArchivaRepositoryScanningTaskExecutorTest Properties properties = jdoFactory.getProperties(); - for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry entry : properties.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); } @@ -158,7 +156,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest taskExecutor.executeTask( repoTask ); ArtifactDAO adao = dao.getArtifactDAO(); - List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); assertNotNull( unprocessedResultList ); assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() ); diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java index 3eb9166c6..47029880e 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java @@ -21,17 +21,15 @@ package org.apache.maven.archiva.security; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.authentication.AuthenticationResult; import org.codehaus.plexus.redback.authorization.AuthorizationException; import org.codehaus.plexus.redback.rbac.RBACManager; -import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException; import org.codehaus.plexus.redback.rbac.RbacManagerException; +import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException; import org.codehaus.plexus.redback.rbac.Role; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; @@ -198,14 +196,10 @@ public class DefaultUserRepositories try { - Collection roleList = rbacManager.getEffectivelyAssignedRoles( principal ); + Collection roleList = rbacManager.getEffectivelyAssignedRoles( principal ); - Iterator it = roleList.iterator(); - - while ( it.hasNext() ) + for ( Role role : roleList ) { - Role role = (Role) it.next(); - String roleName = role.getName(); if ( roleName.startsWith( ArchivaRoleConstants.REPOSITORY_MANAGER_ROLE_PREFIX ) ) diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/SecurityStartup.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/SecurityStartup.java index b81b7a5fa..20d1b6fd4 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/SecurityStartup.java +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/SecurityStartup.java @@ -70,11 +70,6 @@ public class SecurityStartup */ private ArchivaConfiguration archivaConfiguration; - /** - * @plexus.requirement - */ - private ArchivaXworkUser archivaXworkUser; - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) { if ( ConfigurationNames.isManagedRepositories( propertyName ) )