mirror of https://github.com/apache/archiva.git
o don't just crap out when converting a List of artifacts, record the failure and move on.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@471360 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4768ed8288
commit
c65e246bfa
|
@ -105,7 +105,9 @@ public class DefaultRepositoryConverter
|
||||||
*/
|
*/
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
|
|
||||||
public void convert( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter )
|
public void convert( Artifact artifact,
|
||||||
|
ArtifactRepository targetRepository,
|
||||||
|
ReportingDatabase reporter )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) )
|
if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) )
|
||||||
|
@ -163,8 +165,10 @@ public class DefaultRepositoryConverter
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository targetRepository,
|
private void updateMetadata( RepositoryMetadata artifactMetadata,
|
||||||
Metadata newMetadata, FileTransaction transaction )
|
ArtifactRepository targetRepository,
|
||||||
|
Metadata newMetadata,
|
||||||
|
FileTransaction transaction )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
File file = new File( targetRepository.getBasedir(),
|
File file = new File( targetRepository.getBasedir(),
|
||||||
|
@ -238,7 +242,8 @@ public class DefaultRepositoryConverter
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateMetadata( Artifact artifact, ReportingDatabase reporter )
|
private boolean validateMetadata( Artifact artifact,
|
||||||
|
ReportingDatabase reporter )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
ArtifactRepository repository = artifact.getRepository();
|
ArtifactRepository repository = artifact.getRepository();
|
||||||
|
@ -265,7 +270,9 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact,
|
private boolean validateMetadata( Metadata metadata,
|
||||||
|
RepositoryMetadata repositoryMetadata,
|
||||||
|
Artifact artifact,
|
||||||
ReportingDatabase reporter )
|
ReportingDatabase reporter )
|
||||||
{
|
{
|
||||||
String groupIdKey;
|
String groupIdKey;
|
||||||
|
@ -368,25 +375,33 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFailure( ReportingDatabase reporter, Artifact artifact, String key )
|
private void addFailure( ReportingDatabase reporter,
|
||||||
|
Artifact artifact,
|
||||||
|
String key )
|
||||||
{
|
{
|
||||||
addFailureWithReason( reporter, artifact, getI18NString( key ) );
|
addFailureWithReason( reporter, artifact, getI18NString( key ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addWarning( ReportingDatabase reporter, Artifact artifact, String message )
|
private static void addWarning( ReportingDatabase reporter,
|
||||||
|
Artifact artifact,
|
||||||
|
String message )
|
||||||
{
|
{
|
||||||
// TODO: should we be able to identify/fix these?
|
// TODO: should we be able to identify/fix these?
|
||||||
reporter.addWarning( artifact, null, null, message );
|
reporter.addWarning( artifact, null, null, message );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addFailureWithReason( ReportingDatabase reporter, Artifact artifact, String reason )
|
private static void addFailureWithReason( ReportingDatabase reporter,
|
||||||
|
Artifact artifact,
|
||||||
|
String reason )
|
||||||
{
|
{
|
||||||
// TODO: should we be able to identify/fix these?
|
// TODO: should we be able to identify/fix these?
|
||||||
reporter.addFailure( artifact, null, null, reason );
|
reporter.addFailure( artifact, null, null, reason );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter,
|
private boolean copyPom( Artifact artifact,
|
||||||
|
ArtifactRepository targetRepository,
|
||||||
|
ReportingDatabase reporter,
|
||||||
FileTransaction transaction )
|
FileTransaction transaction )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
|
@ -505,8 +520,10 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doRelocation( Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model,
|
private boolean doRelocation( Artifact artifact,
|
||||||
ArtifactRepository repository, FileTransaction transaction )
|
org.apache.maven.model.v3_0_0.Model v3Model,
|
||||||
|
ArtifactRepository repository,
|
||||||
|
FileTransaction transaction )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Properties properties = v3Model.getProperties();
|
Properties properties = v3Model.getProperties();
|
||||||
|
@ -549,9 +566,15 @@ public class DefaultRepositoryConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId,
|
private void writeRelocationPom( String groupId,
|
||||||
String newArtifactId, String newVersion, String message,
|
String artifactId,
|
||||||
ArtifactRepository repository, FileTransaction transaction )
|
String version,
|
||||||
|
String newGroupId,
|
||||||
|
String newArtifactId,
|
||||||
|
String newVersion,
|
||||||
|
String message,
|
||||||
|
ArtifactRepository repository,
|
||||||
|
FileTransaction transaction )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Model pom = new Model();
|
Model pom = new Model();
|
||||||
|
@ -584,7 +607,8 @@ public class DefaultRepositoryConverter
|
||||||
transaction.createFile( strWriter.toString(), pomFile );
|
transaction.createFile( strWriter.toString(), pomFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getI18NString( String key, String arg0 )
|
private String getI18NString( String key,
|
||||||
|
String arg0 )
|
||||||
{
|
{
|
||||||
return i18n.format( getClass().getName(), Locale.getDefault(), key, arg0 );
|
return i18n.format( getClass().getName(), Locale.getDefault(), key, arg0 );
|
||||||
}
|
}
|
||||||
|
@ -594,7 +618,9 @@ public class DefaultRepositoryConverter
|
||||||
return i18n.getString( getClass().getName(), Locale.getDefault(), key );
|
return i18n.getString( getClass().getName(), Locale.getDefault(), key );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testChecksums( Artifact artifact, File file, ReportingDatabase reporter )
|
private boolean testChecksums( Artifact artifact,
|
||||||
|
File file,
|
||||||
|
ReportingDatabase reporter )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -605,8 +631,12 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean verifyChecksum( File file, String fileName, Digester digester, ReportingDatabase reporter,
|
private boolean verifyChecksum( File file,
|
||||||
Artifact artifact, String key )
|
String fileName,
|
||||||
|
Digester digester,
|
||||||
|
ReportingDatabase reporter,
|
||||||
|
Artifact artifact,
|
||||||
|
String key )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
@ -628,7 +658,9 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, ReportingDatabase reporter,
|
private boolean copyArtifact( Artifact artifact,
|
||||||
|
ArtifactRepository targetRepository,
|
||||||
|
ReportingDatabase reporter,
|
||||||
FileTransaction transaction )
|
FileTransaction transaction )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
|
@ -671,13 +703,32 @@ public class DefaultRepositoryConverter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convert( List artifacts, ArtifactRepository targetRepository, ReportingDatabase reporter )
|
public void convert( List artifacts,
|
||||||
|
ArtifactRepository targetRepository,
|
||||||
|
ReportingDatabase reporter )
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Artifact artifact = (Artifact) i.next();
|
Artifact artifact = (Artifact) i.next();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
convert( artifact, targetRepository, reporter );
|
convert( artifact, targetRepository, reporter );
|
||||||
}
|
}
|
||||||
|
catch ( RepositoryConversionException e )
|
||||||
|
{
|
||||||
|
// Need to add:
|
||||||
|
// artifact
|
||||||
|
// processor
|
||||||
|
// problem
|
||||||
|
// reason
|
||||||
|
//TODO: this doesn't really provide any real facility for a decent error message, having
|
||||||
|
// the stack trace would be useful. I also have no idea what a processor is currently or
|
||||||
|
// how to get hold of it here.
|
||||||
|
|
||||||
|
reporter.addFailure( artifact, "", e.getLocalizedMessage(), e.getCause().getLocalizedMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue