*/
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" );
return false;
}
- public List getExcludes()
+ public List<String> getExcludes()
{
return null;
}
- public List getIncludes()
+ public List<String> getIncludes()
{
return includes;
}
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" );
}
return false;
}
- public List getExcludes()
+ public List<String> getExcludes()
{
return null;
}
- public List getIncludes()
+ public List<String> getIncludes()
{
return includes;
}
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import java.util.List;
import java.util.Map;
/**
*
* @return the {@link Map}<{@link Artifact}, {@link String}> warning messages.
*/
- Map getWarnings();
+ Map<Artifact, List<String>> getWarnings();
/**
* Clear the list of warning messages.
* 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;
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
*
*
* @plexus.requirement role="org.codehaus.plexus.digest.Digester"
*/
- private List digesters;
+ private List<Digester> digesters;
/**
* @plexus.requirement
*/
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
}
}
+ @SuppressWarnings("unchecked")
private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction )
throws ArtifactConversionException
{
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 );
}
}
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$
}
return result;
}
+ @SuppressWarnings("unchecked")
private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact )
{
String groupIdKey;
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;
}
}
}
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 );
warnings.clear();
}
- public Map getWarnings()
+ public Map<Artifact, List<String>> getWarnings()
{
return warnings;
}
* 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;
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
*
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 );
{
// 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() ) );
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;
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 );
}
}
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 )
* 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 )
* 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;
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
*
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() );
}
countComplete++;
}
- public List getIncludedTypes()
+ public List<String> getIncludedTypes()
{
return null;
}
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;
* 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;
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 );
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;
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.
*/
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>();
/* do nothing */
}
- public List getIncludedTypes()
+ public List<String> getIncludedTypes()
{
return null;
}
* 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.
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 )
{
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;
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.
* 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
*
*/
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 ) );
* 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
*
*/
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 ) );
* 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
*
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() );
}
* 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;
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
*
// 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() );
}
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 );
}
}
* 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;
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.
*
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
{
}
}
} );
- return (String) o;
}
protected String checksumFile( String file )
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;
*/
private ArchivaConfiguration archivaConfiguration;
- /**
- * @plexus.requirement
- */
- private ArchivaXworkUser archivaXworkUser;
-
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
if ( ConfigurationNames.isManagedRepositories( propertyName ) )