add null check as mock can return null

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1400336 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-19 23:16:50 +00:00
parent daeb71afc0
commit 8a6a292a68
1 changed files with 32 additions and 27 deletions

View File

@ -120,6 +120,8 @@ public abstract class AbstractRepositoryPurge
Collection<ArtifactMetadata> artifacts =
metadataRepository.getArtifacts( repository.getId(), reference.getGroupId(),
reference.getArtifactId(), baseVersion );
if ( artifacts != null )
{
// cleanup snapshots metadata
for ( ArtifactMetadata artifactMetadata : artifacts )
{
@ -132,13 +134,15 @@ public abstract class AbstractRepositoryPurge
// cleanup facet which contains classifier information
MavenArtifactFacet mavenArtifactFacet =
(MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
(MavenArtifactFacet) artifactMetadata.getFacet(
MavenArtifactFacet.FACET_ID );
if ( StringUtils.equals( reference.getClassifier(),
mavenArtifactFacet.getClassifier() ) )
{
artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID );
String groupId = reference.getGroupId(), artifactId = reference.getArtifactId(),
String groupId = reference.getGroupId(), artifactId =
reference.getArtifactId(),
version = reference.getVersion();
MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet();
mavenArtifactFacetToCompare.setClassifier( reference.getClassifier() );
@ -158,6 +162,7 @@ public abstract class AbstractRepositoryPurge
}
}
}
}
catch ( MetadataResolutionException e )
{
log.warn( "skip error deleting metadata {}: {}", reference, e.getMessage() );