use private static inner class

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1338244 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-05-14 15:08:53 +00:00
parent 58b6759ae5
commit 87e09e5ca3
1 changed files with 45 additions and 23 deletions

View File

@ -645,33 +645,12 @@ public class Maven2RepositoryStorage
File[] files;
if ( VersionUtil.isSnapshot( projectVersion ) )
{
files = dir.listFiles( new FilenameFilter()
{
public boolean accept( File dir, String name )
{
if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) )
{
String v = name.substring( artifactId.length() + 1, name.length() - 4 );
v = VersionUtil.getBaseVersion( v );
if ( v.equals( projectVersion ) )
{
return true;
}
}
return false;
}
} );
files = dir.listFiles( new PomFilenameFilter( artifactId, projectVersion ) );
}
else
{
final String pomFile = artifactId + "-" + projectVersion + ".pom";
files = dir.listFiles( new FilenameFilter()
{
public boolean accept( File dir, String name )
{
return pomFile.equals( name );
}
} );
files = dir.listFiles( new PomFileFilter( pomFile ) );
}
if ( files != null && files.length > 0 )
{
@ -770,4 +749,47 @@ public class Maven2RepositoryStorage
return true;
}
}
private static class PomFilenameFilter
implements FilenameFilter
{
private final String artifactId, projectVersion;
private PomFilenameFilter( String artifactId, String projectVersion )
{
this.artifactId = artifactId;
this.projectVersion = projectVersion;
}
public boolean accept( File dir, String name )
{
if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) )
{
String v = name.substring( artifactId.length() + 1, name.length() - 4 );
v = VersionUtil.getBaseVersion( v );
if ( v.equals( projectVersion ) )
{
return true;
}
}
return false;
}
}
private static class PomFileFilter
implements FilenameFilter
{
private final String pomFile;
private PomFileFilter( String pomFile )
{
this.pomFile = pomFile;
}
public boolean accept( File dir, String name )
{
return pomFile.equals( name );
}
}
}