if ( ( snapshot && !managedRepository.isSnapshots() ) || ( !snapshot
&& managedRepository.isSnapshots() ) )
{
continue;
}
ManagedRepositoryContent managedRepositoryContent =
repositoryContentFactory.getManagedRepositoryContent( repoId );
// FIXME default to jar which can be wrong for war zip etc....
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version,
StringUtils.isEmpty( classifier )
? ""
: classifier, "jar", repoId
);
File file = managedRepositoryContent.toFile( archivaArtifact );
if ( file != null && file.exists() )
{
return true;
}
// in case of SNAPSHOT we can have timestamped version locally !
if ( StringUtils.endsWith( version, VersionUtil.SNAPSHOT ) )
{
File metadataFile = new File( file.getParent(), MetadataTools.MAVEN_METADATA );
if ( metadataFile.exists() )
{
try
{
ArchivaRepositoryMetadata archivaRepositoryMetadata =
MavenMetadataReader.read( metadataFile );
int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
String timeStamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
// rebuild file name with timestamped version and build number
String timeStampFileName = new StringBuilder( artifactId ).append( '-' ) //
.append( StringUtils.remove( version, "-" + VersionUtil.SNAPSHOT ) ) //
.append( '-' ).append( timeStamp ) //
.append( '-' ).append( Integer.toString( buildNumber ) ) //
.append( ( StringUtils.isEmpty( classifier ) ? "" : "-" + classifier ) ) //
.append( ".jar" ).toString();
File timeStampFile = new File( file.getParent(), timeStampFileName );
log.debug( "try to find timestamped snapshot version file: {}", timeStampFile.getPath() );
if ( timeStampFile.exists() )
{
return true;
}
}
catch ( XMLException e )
{
log.warn( "skip fail to find timestamped snapshot file: {}", e.getMessage() );
}
}
}
String path = managedRepositoryContent.toPath( archivaArtifact );
file = connectors.fetchFromProxies( managedRepositoryContent, path );
if ( file != null && file.exists() )
{