List pluginDirs = getArtifactIdFiles( metadataDir );
Map prefixes = new HashMap();
for ( Iterator plugins = metadata.getMetadata().getPlugins().iterator(); plugins.hasNext(); )
{
Plugin plugin = (Plugin) plugins.next();
String artifactId = plugin.getArtifactId();
if ( artifactId == null || artifactId.length() == 0 )
{
addFailure( metadata, "missing-artifact-id:" + plugin.getPrefix(),
"Missing or empty artifactId in group metadata for plugin " + plugin.getPrefix() );
}
String prefix = plugin.getPrefix();
if ( prefix == null || prefix.length() == 0 )
{
addFailure( metadata, "missing-plugin-prefix:" + artifactId,
"Missing or empty plugin prefix for artifactId " + artifactId + "." );
}
else
{
if ( prefixes.containsKey( prefix ) )
{
addFailure( metadata, "duplicate-plugin-prefix:" + prefix, "Duplicate plugin prefix found: "
+ prefix + "." );
}
else
{
prefixes.put( prefix, plugin );
}
}
if ( artifactId != null && artifactId.length() > 0 )
{
File pluginDir = new File( metadataDir, artifactId );
if ( !pluginDirs.contains( pluginDir ) )
{
addFailure( metadata, "missing-plugin-from-repository:" + artifactId, "Metadata plugin "
+ artifactId + " not found in the repository" );
}
else
{
pluginDirs.remove( pluginDir );
}
}
}
if ( pluginDirs.size() > 0 )
{
for ( Iterator plugins = pluginDirs.iterator(); plugins.hasNext(); )
{
File plugin = (File) plugins.next();
addFailure( metadata, "missing-plugin-from-metadata:" + plugin.getName(), "Plugin " + plugin.getName()
+ " is present in the repository but " + "missing in the metadata." );
}
}
}