]> source.dussan.org Git - archiva.git/commitdiff
start adding Java5 features to modules
authorBrett Porter <brett@apache.org>
Tue, 17 Mar 2009 13:40:10 +0000 (13:40 +0000)
committerBrett Porter <brett@apache.org>
Tue, 17 Mar 2009 13:40:10 +0000 (13:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755239 13f79535-47bb-0310-9956-ffa450edef68

20 files changed:
archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/ArtifactConverter.java
archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java
archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArtifactDAO.java
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java
archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java
archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/CorruptArtifactReport.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsReport.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldArtifactReport.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/OldSnapshotArtifactReport.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/AbstractArtifactReportsTestCase.java
archiva-modules/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java
archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/maven/archiva/applet/ChecksumApplet.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java

index bb3a7146cc24601f210bbcfeaffc23431e0fb360..bfc5f6ebc76c6e273581f59904a434567bfb9069 100644 (file)
@@ -47,12 +47,12 @@ public class ArtifactCountConsumer
      */
     private String description;
 
-    private List includes;
+    private List<String> includes;
 
     public ArtifactCountConsumer()
     {
         // TODO: shouldn't this use filetypes?
-        includes = new ArrayList();
+        includes = new ArrayList<String>();
         includes.add( "**/*.pom" );
         includes.add( "**/*.jar" );
         includes.add( "**/*.war" );
@@ -82,12 +82,12 @@ public class ArtifactCountConsumer
         return false;
     }
 
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return null;
     }
 
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return includes;
     }
index b0eb6edc06f22d5f7bc53383d68647ebcfcf00b7..be19a1a01de28524315a21a7cd77bc90acc2c7fc 100644 (file)
@@ -59,13 +59,13 @@ public class ProjectReaderConsumer
 
     private ManagedRepositoryConfiguration repo;
 
-    private List includes;
+    private List<String> includes;
 
     public ProjectReaderConsumer()
     {
         reader = new ProjectModel400Reader();
 
-        includes = new ArrayList();
+        includes = new ArrayList<String>();
         includes.add( "**/*.pom" );
     }
 
@@ -84,12 +84,12 @@ public class ProjectReaderConsumer
         return false;
     }
 
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return null;
     }
 
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return includes;
     }
index 1c67d8d2a8214281eead09cf37d95c759d761df3..fc61d16a07c29a25d9eed9aa49cd167b41834b04 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.converter.artifact;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -48,7 +49,7 @@ public interface ArtifactConverter
      * 
      * @return the {@link Map}&lt;{@link Artifact}, {@link String}&gt; warning messages.
      */
-    Map getWarnings();
+    Map<Artifact, List<String>> getWarnings();
 
     /**
      * Clear the list of warning messages.
index 8ce135b9fd0058baed751d73cf86850645cdb9de..f1f16601b1d1681f497d02d907881bf8a08d20c6 100644 (file)
@@ -19,6 +19,19 @@ package org.apache.maven.archiva.converter.artifact;
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.maven.archiva.transaction.FileTransaction;
@@ -45,20 +58,6 @@ import org.codehaus.plexus.digest.Digester;
 import org.codehaus.plexus.digest.DigesterException;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-
 /**
  * LegacyToDefaultConverter 
  *
@@ -75,7 +74,7 @@ public class LegacyToDefaultConverter
      * 
      * @plexus.requirement role="org.codehaus.plexus.digest.Digester"
      */
-    private List digesters;
+    private List<Digester> digesters;
 
     /**
      * @plexus.requirement
@@ -102,7 +101,7 @@ public class LegacyToDefaultConverter
      */
     private boolean dryrun;
 
-    private Map warnings = new HashMap();
+    private Map<Artifact,List<String>> warnings = new HashMap<Artifact,List<String>>();
 
     public void convert( Artifact artifact, ArtifactRepository targetRepository )
         throws ArtifactConversionException
@@ -168,6 +167,7 @@ public class LegacyToDefaultConverter
         }
     }
 
+    @SuppressWarnings("unchecked")
     private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction )
         throws ArtifactConversionException
     {
@@ -250,11 +250,10 @@ public class LegacyToDefaultConverter
 
                     transaction.createFile( writer.toString(), targetFile, digesters );
 
-                    List warnings = translator.getWarnings();
+                    List<String> warnings = translator.getWarnings();
 
-                    for ( Iterator i = warnings.iterator(); i.hasNext(); )
+                    for ( String message : warnings )
                     {
-                        String message = (String) i.next();
                         addWarning( artifact, message );
                     }
                 }
@@ -289,10 +288,8 @@ public class LegacyToDefaultConverter
         throws IOException
     {
         boolean result = true;
-        Iterator it = digesters.iterator();
-        while ( it.hasNext() )
+        for ( Digester digester : digesters )
         {
-            Digester digester = (Digester) it.next();
             result &= verifyChecksum( file, file.getName() + "." + getDigesterFileExtension( digester ), digester, //$NON-NLS-1$
                                       artifact, "failure.incorrect." + getDigesterFileExtension( digester ) ); //$NON-NLS-1$
         }
@@ -441,6 +438,7 @@ public class LegacyToDefaultConverter
         return result;
     }
 
+    @SuppressWarnings("unchecked")
     private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact )
     {
         String groupIdKey;
@@ -488,12 +486,12 @@ public class LegacyToDefaultConverter
                 boolean foundVersion = false;
                 if ( metadata.getVersioning() != null )
                 {
-                    for ( Iterator i = metadata.getVersioning().getVersions().iterator(); i.hasNext() && !foundVersion; )
+                    for ( String version : (List<String>) metadata.getVersioning().getVersions() )
                     {
-                        String version = (String) i.next();
                         if ( version.equals( artifact.getBaseVersion() ) )
                         {
                             foundVersion = true;
+                            break;
                         }
                     }
                 }
@@ -668,10 +666,10 @@ public class LegacyToDefaultConverter
 
     private void addWarning( Artifact artifact, String message )
     {
-        List messages = (List) warnings.get( artifact );
+        List<String> messages = warnings.get( artifact );
         if ( messages == null )
         {
-            messages = new ArrayList();
+            messages = new ArrayList<String>();
         }
         messages.add( message );
         warnings.put( artifact, messages );
@@ -682,7 +680,7 @@ public class LegacyToDefaultConverter
         warnings.clear();
     }
 
-    public Map getWarnings()
+    public Map<Artifact, List<String>> getWarnings()
     {
         return warnings;
     }
index a305f1349a3d90da24fd3fd9cd24469d58c5f152..8ce2f2c8a7d896c890d5cf0b0aafecc67ea1877f 100644 (file)
@@ -19,6 +19,15 @@ package org.apache.maven.archiva.converter.artifact;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -30,17 +39,6 @@ import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
 import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-
 /**
  * LegacyToDefaultConverterTest 
  *
@@ -736,19 +734,21 @@ public class LegacyToDefaultConverterTest
 
         boolean found = false;
         String pattern = "^" + Messages.getString( "invalid.source.pom" ).replaceFirst( "\\{0\\}", ".*" ) + "$";
-        for ( Iterator it = artifactConverter.getWarnings().values().iterator(); it.hasNext() && !found; )
+        for ( List<String> messages : artifactConverter.getWarnings().values() )
         {
-            List messages = (List) it.next();
-
-            for ( Iterator itmsgs = messages.iterator(); itmsgs.hasNext(); )
+            for ( String message : messages )
             {
-                String message = (String) itmsgs.next();
                 if ( message.matches( pattern ) )
                 {
                     found = true;
                     break;
                 }
             }
+            
+            if ( found )
+            {
+                break;
+            }
         }
 
         assertTrue( "Check failure message.", found );
@@ -763,22 +763,19 @@ public class LegacyToDefaultConverterTest
     {
         // test multiple artifacts are converted
 
-        List artifacts = new ArrayList();
+        List<Artifact> artifacts = new ArrayList<Artifact>();
         artifacts.add( createArtifact( "test", "artifact-one", "1.0.0" ) );
         artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) );
         artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) );
 
-        for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+        for ( Artifact artifact : artifacts )
         {
-            Artifact arti = (Artifact) it.next();
-            artifactConverter.convert( arti, targetRepository );
+            artifactConverter.convert( artifact, targetRepository );
             checkSuccess( artifactConverter );
         }
 
-        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+        for ( Artifact artifact : artifacts )
         {
-            Artifact artifact = (Artifact) i.next();
-
             File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
             assertTrue( "Check artifact created", artifactFile.exists() );
             assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) );
@@ -954,9 +951,8 @@ public class LegacyToDefaultConverterTest
     private int countWarningMessages( ArtifactConverter converter )
     {
         int count = 0;
-        for ( Iterator it = converter.getWarnings().values().iterator(); it.hasNext(); )
+        for ( List<String> values : converter.getWarnings().values() )
         {
-            List values = (List) it.next();
             count += values.size();
         }
         return count;
@@ -967,28 +963,25 @@ public class LegacyToDefaultConverterTest
         assertNotNull( "Warnings should never be null.", converter.getWarnings() );
         assertTrue( "Expecting 1 or more Warnings", countWarningMessages( converter ) > 0 );
 
-        for ( Iterator it = converter.getWarnings().values().iterator(); it.hasNext(); )
+        for ( List<String> messages : converter.getWarnings().values() )
         {
-            List messages = (List) it.next();
             if ( messages.contains( reason ) )
             {
-                /* No need to check any furthor */
+                /* No need to check any further */
                 return;
             }
         }
 
         /* didn't find it. */
 
-        for ( Iterator it = converter.getWarnings().entrySet().iterator(); it.hasNext(); )
+        for ( Map.Entry<Artifact,List<String>> entry : converter.getWarnings().entrySet() )
         {
-            Map.Entry entry = (Entry) it.next();
             Artifact artifact = (Artifact) entry.getKey();
             System.out.println( "-Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
                 + artifact.getVersion() );
-            List messages = (List) entry.getValue();
-            for ( Iterator itmsgs = messages.iterator(); itmsgs.hasNext(); )
+            List<String> messages = entry.getValue();
+            for ( String message : messages )
             {
-                String message = (String) itmsgs.next();
                 System.out.println( "  " + message );
             }
         }
index baca256603d53aec26dc87812d1b27e9815b3915..2c8d901fe9e45afd043f3bb4cb6702dd06ebdd87 100644 (file)
@@ -58,7 +58,7 @@ public interface ArtifactDAO
                                         String type, String repositoryId )
         throws ObjectNotFoundException, ArchivaDatabaseException;
 
-    public List /*<ArchivaArtifact>*/queryArtifacts( Constraint constraint )
+    public List<ArchivaArtifact> queryArtifacts( Constraint constraint )
         throws ObjectNotFoundException, ArchivaDatabaseException;
 
     public ArchivaArtifact saveArtifact( ArchivaArtifact artifact )
index b43a6d7466a71c689eaf3493d299ce6b522bdf64..212a538a93a58188a46856e8ce755b577358eb4d 100644 (file)
@@ -51,7 +51,7 @@ public interface RepositoryProblemDAO
      * This is the only list of options created in this DAO.
      */
 
-    public List /*<RepositoryProblem>*/queryRepositoryProblems( Constraint constraint )
+    public List <RepositoryProblem> queryRepositoryProblems( Constraint constraint )
         throws ObjectNotFoundException, ArchivaDatabaseException;
 
     public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem )
index 0cbc95f9c166677618b430bafb9afeea61f9d651..6a3aaa8d4b3bc592f94b590e99b6ac8ec99a06a1 100644 (file)
@@ -19,6 +19,16 @@ package org.apache.maven.archiva.database;
  * under the License.
  */
 
+import java.io.File;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.updater.DatabaseCleanupConsumer;
 import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer;
@@ -31,17 +41,6 @@ import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.jpox.SchemaTool;
 
-import java.io.File;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
 /**
  * AbstractArchivaDatabaseTestCase 
  *
@@ -103,10 +102,8 @@ public abstract class AbstractArchivaDatabaseTestCase
 
         Properties properties = jdoFactory.getProperties();
 
-        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+        for ( Map.Entry<Object,Object> entry : properties.entrySet() )
         {
-            Map.Entry entry = (Map.Entry) it.next();
-
             System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
         }
 
index 12cc9b6bde58bbf5d9b3133d7ae5786edca74438..4cc47a0df3aae03e9d3b08522b43acb0d1f07547 100644 (file)
@@ -55,7 +55,7 @@ public class TestDatabaseCleanupConsumer
         countComplete++;
     }
 
-    public List getIncludedTypes()
+    public List<String> getIncludedTypes()
     {
         return null;
     }
index d059a4a659edab033c429ab9e890458a3d1ef9bf..f35dd67d650051fa1f1a662f69b40440d04b0ec8 100644 (file)
@@ -62,9 +62,9 @@ public class TestDatabaseUnprocessedConsumer
         countComplete++;
     }
 
-    public List getIncludedTypes()
+    public List<String> getIncludedTypes()
     {
-        List types = new ArrayList();
+        List<String> types = new ArrayList<String>();
         types.add( "pom" );
         types.add( "jar" );
         return types;
index 502489310eb921d63f2a59189b8160858623c34d..c9280e8530b89e071495a3f52b7527a57d248d9a 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.reporting.artifact;
  * under the License.
  */
 
+import org.apache.maven.archiva.model.RepositoryProblem;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 import org.apache.maven.archiva.reporting.DataLimits;
 import org.apache.maven.archiva.database.ArchivaDAO;
@@ -56,13 +57,13 @@ public class CorruptArtifactReport
         constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_CORRUPT_ARTIFACT );
     }
 
-    public List getData()
+    public List<RepositoryProblem> getData()
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
     }
 
-    public List getData( DataLimits limits )
+    public List<RepositoryProblem> getData( DataLimits limits )
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
index 1e1d774b0e954d2e841ee782ef7a5b2d0e9a4cdf..abf2ccb9112ac6f60c5baa45eb5e7255cb4c868a 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.Constraint;
 import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.constraints.RepositoryProblemByTypeConstraint;
+import org.apache.maven.archiva.model.RepositoryProblem;
 import org.apache.maven.archiva.reporting.DataLimits;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 
@@ -59,13 +60,13 @@ public class DuplicateArtifactReport
         constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_DUPLICATE_ARTIFACTS );
     }
 
-    public List getData()
+    public List<RepositoryProblem> getData()
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
     }
 
-    public List getData( DataLimits limits )
+    public List<RepositoryProblem> getData( DataLimits limits )
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         // TODO: implement limits.        
index ac175ed27b6a39a864269ba1fedd4cd61d3ae8bf..2929abedfba49d4c3e6b58af11dd8065d35189a5 100644 (file)
@@ -98,7 +98,8 @@ public class LocationArtifactsConsumer
      */
     private RepositoryContentFactory repositoryFactory;
 
-    private Map repositoryMap = new HashMap();
+    private Map<String, ManagedRepositoryConfiguration> repositoryMap =
+        new HashMap<String, ManagedRepositoryConfiguration>();
 
     // TODO: why is this not used? If it should be, what about excludes?
     private List<String> includes = new ArrayList<String>();
@@ -128,7 +129,7 @@ public class LocationArtifactsConsumer
         /* do nothing */
     }
 
-    public List getIncludedTypes()
+    public List<String> getIncludedTypes()
     {
         return null;
     }
@@ -203,7 +204,7 @@ public class LocationArtifactsConsumer
             * indicate that the artifact is, indeed located in the wrong place.
             */
 
-            List actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" );
+            List<JarEntry> actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" );
             if ( actualPomXmls.isEmpty() )
             {
                 // No check needed.
@@ -267,27 +268,27 @@ public class LocationArtifactsConsumer
 
     private ArchivaProjectModel readFilesystemModel( File artifactFile )
     {
-        File pomFile = createPomFileReference( artifactFile );
+//        File pomFile = createPomFileReference( artifactFile );
 
         // TODO: read and resolve model here.
 
         return null;
     }
 
-    private File createPomFileReference( File artifactFile )
-    {
-        String pomFilename = artifactFile.getAbsolutePath();
-
-        int pos = pomFilename.lastIndexOf( '.' );
-        if ( pos <= 0 )
-        {
-            // Invalid filename.
-            return null;
-        }
-
-        pomFilename = pomFilename.substring( 0, pos ) + ".pom";
-        return new File( pomFilename );
-    }
+//    private File createPomFileReference( File artifactFile )
+//    {
+//        String pomFilename = artifactFile.getAbsolutePath();
+//
+//        int pos = pomFilename.lastIndexOf( '.' );
+//        if ( pos <= 0 )
+//        {
+//            // Invalid filename.
+//            return null;
+//        }
+//
+//        pomFilename = pomFilename.substring( 0, pos ) + ".pom";
+//        return new File( pomFilename );
+//    }
 
     private ManagedRepositoryConfiguration findRepository( ArchivaArtifact artifact )
     {
index d419bcafc84738859ae7291d5602c2230e7278f5..9a3f232eff36c5cba14e0d71c6b64ee970a53634 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.Constraint;
 import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.constraints.RepositoryProblemByTypeConstraint;
+import org.apache.maven.archiva.model.RepositoryProblem;
 import org.apache.maven.archiva.reporting.DataLimits;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 
@@ -59,13 +60,13 @@ public class LocationArtifactsReport
         constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_BAD_ARTIFACT_LOCATION );
     }
 
-    public List getData()
+    public List<RepositoryProblem> getData()
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
     }
 
-    public List getData( DataLimits limits )
+    public List<RepositoryProblem> getData( DataLimits limits )
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         // TODO: implement limits.
index 6cf545d1d7bf25741707972652389fb8577cc7d6..4a40c80bda62cb74deb63110e11371d207d4d612 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.maven.archiva.reporting.artifact;
  * under the License.
  */
 
+import java.util.List;
+
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.constraints.OlderArtifactsByAgeConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.reporting.DataLimits;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 
-import java.util.List;
-
 /**
  * OldArtifactReport 
  *
@@ -56,13 +57,13 @@ public class OldArtifactReport
      */
     private int cutoffDays;
 
-    public List getData()
+    public List<ArchivaArtifact> getData()
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getArtifactDAO().queryArtifacts( new OlderArtifactsByAgeConstraint( cutoffDays ) );
     }
 
-    public List getData( DataLimits limits )
+    public List<ArchivaArtifact> getData( DataLimits limits )
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getArtifactDAO().queryArtifacts( new OlderArtifactsByAgeConstraint( cutoffDays ) );
index 82d4160eb3ca83c0b84aec819fd8a23cd2b7c7dc..b3c217d039648d6a67473d84bc7ea53e583b3fa0 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.maven.archiva.reporting.artifact;
  * under the License.
  */
 
+import java.util.List;
+
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.constraints.OlderSnapshotArtifactsByAgeConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.reporting.DataLimits;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 
-import java.util.List;
-
 /**
  * OldSnapshotArtifactReport 
  *
@@ -56,13 +57,13 @@ public class OldSnapshotArtifactReport
      */
     private int cutoffDays;
 
-    public List getData()
+    public List<ArchivaArtifact> getData()
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getArtifactDAO().queryArtifacts( new OlderSnapshotArtifactsByAgeConstraint( cutoffDays ) );
     }
 
-    public List getData( DataLimits limits )
+    public List<ArchivaArtifact> getData( DataLimits limits )
         throws ObjectNotFoundException, ArchivaDatabaseException
     {
         return dao.getArtifactDAO().queryArtifacts( new OlderSnapshotArtifactsByAgeConstraint( cutoffDays ) );
index a28eb073e4bb9a5858c04ca56a553734144c59ca..2ff436a080dc2be61684a182cd0fd60913bd066d 100644 (file)
@@ -19,21 +19,20 @@ package org.apache.maven.archiva.reporting.artifact;
  * under the License.
  */
 
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.jdo.JdoFactory;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-import org.jpox.SchemaTool;
-
 import java.io.File;
 import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
 import java.util.Properties;
+import java.util.Map.Entry;
 
 import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.jdo.JdoFactory;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.jpox.SchemaTool;
+
 /**
  * AbstractArtifactReportsTestCase 
  *
@@ -92,10 +91,8 @@ public abstract class AbstractArtifactReportsTestCase
 
         Properties properties = jdoFactory.getProperties();
 
-        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+        for ( Entry<Object, Object> entry : properties.entrySet() )
         {
-            Map.Entry entry = (Map.Entry) it.next();
-
             System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
         }
 
index 96dddd5c8c8fb2b9acea6c278b4e72cdd8674d69..4f44f731112086e8c8b3827fb34cb67ac77bdf4b 100644 (file)
@@ -19,6 +19,10 @@ package org.apache.maven.archiva.reporting.artifact;
  * under the License.
  */
 
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -28,11 +32,6 @@ import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.RepositoryProblem;
 import org.apache.maven.archiva.reporting.DynamicReportSource;
 
-import java.io.File;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * DuplicateArtifactReportTest
  *
@@ -115,20 +114,18 @@ public class DuplicateArtifactReportTest
         // Setup entries for bad/duplicate in problem DB.
         pretendToRunDuplicateArtifactsConsumer();
 
-        List allArtifacts = artifactDao.queryArtifacts( null );
+        List<ArchivaArtifact> allArtifacts = artifactDao.queryArtifacts( null );
         assertEquals( "Total Artifact Count", 7, allArtifacts.size() );
 
         DuplicateArtifactReport report =
             (DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(), "duplicate-artifacts" );
 
-        List results = report.getData();
+        List<RepositoryProblem> results = report.getData();
 
         System.out.println( "Results.size: " + results.size() );
         int i = 0;
-        Iterator it = results.iterator();
-        while ( it.hasNext() )
+        for ( RepositoryProblem problem : results )
         {
-            RepositoryProblem problem = (RepositoryProblem) it.next();
             System.out.println( "[" + ( i++ ) + "] " + problem.getMessage() );
         }
 
@@ -144,16 +141,14 @@ public class DuplicateArtifactReportTest
     private void pretendToRunDuplicateArtifactsConsumer()
         throws Exception
     {
-        List artifacts = dao.getArtifactDAO().queryArtifacts( null );
+        List<ArchivaArtifact> artifacts = dao.getArtifactDAO().queryArtifacts( null );
         ArchivaArtifactConsumer consumer =
             (ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(), "duplicate-artifacts" );
         consumer.beginScan();
         try
         {
-            Iterator it = artifacts.iterator();
-            while ( it.hasNext() )
+            for ( ArchivaArtifact artifact : artifacts )
             {
-                ArchivaArtifact artifact = (ArchivaArtifact) it.next();
                 consumer.processArchivaArtifact( artifact );
             }
         }
index 03d8e33f154e52faf20d6096d9377bb4aaa554fc..5fb4752fd232db56983b969815365ea523d6f11c 100644 (file)
@@ -19,9 +19,8 @@ package org.apache.maven.archiva.applet;
  * under the License.
  */
 
-import javax.swing.*;
 import java.applet.Applet;
-import java.awt.*;
+import java.awt.BorderLayout;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -32,6 +31,9 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivilegedAction;
 
+import javax.swing.JLabel;
+import javax.swing.JProgressBar;
+
 /**
  * Applet that takes a file on the local filesystem and checksums it for sending to the server.
  *
@@ -58,9 +60,9 @@ public class ChecksumApplet
     public String generateMd5( final String file )
         throws IOException, NoSuchAlgorithmException
     {
-        Object o = AccessController.doPrivileged( new PrivilegedAction()
+        return AccessController.doPrivileged( new PrivilegedAction<String>()
         {
-            public Object run()
+            public String run()
             {
                 try
                 {
@@ -80,7 +82,6 @@ public class ChecksumApplet
                 }
             }
         } );
-        return (String) o;
     }
 
     protected String checksumFile( String file )
index 267c1b7de1811aaec12e57fb66970399ff2ab86c..346773abd0e7a22be0fde683d287981ad8102975 100644 (file)
@@ -30,7 +30,6 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ConfigurationNames;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.security.ArchivaXworkUser;
 import org.codehaus.plexus.redback.rbac.RBACManager;
 import org.codehaus.plexus.redback.rbac.RbacManagerException;
 import org.codehaus.plexus.redback.rbac.UserAssignment;
@@ -75,11 +74,6 @@ public class SecuritySynchronization
      */
     private ArchivaConfiguration archivaConfiguration;
 
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaXworkUser archivaXworkUser;
-
     public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
     {
         if ( ConfigurationNames.isManagedRepositories( propertyName ) )