{
XMLReader xml = new XMLReader( "metadata", metadataFile );
// invoke this to remove namespaces, see MRM-1136
xml.removeNamespaces();
ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
metadata.setArtifactId( xml.getElementText( "//metadata/artifactId" ) );
metadata.setVersion( xml.getElementText( "//metadata/version" ) );
metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
metadata.setFileSize( metadataFile.length() );
metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );
metadata.setReleasedVersion( xml.getElementText( "//metadata/versioning/release" ) );
metadata.setAvailableVersions( xml.getElementListText( "//metadata/versioning/versions/version" ) );
Element snapshotElem = xml.getElement( "//metadata/versioning/snapshot" );
if ( snapshotElem != null )
{
SnapshotVersion snapshot = new SnapshotVersion();
snapshot.setTimestamp( snapshotElem.elementTextTrim( "timestamp" ) );
String tmp = snapshotElem.elementTextTrim( "buildNumber" );
if( NumberUtils.isNumber( tmp ))
{
snapshot.setBuildNumber( NumberUtils.toInt( tmp ) );
}
metadata.setSnapshotVersion( snapshot );
}
for ( Element plugin : xml.getElementList( "//metadata/plugins/plugin" ) )
{
Plugin p = new Plugin();
p.setPrefix( plugin.elementTextTrim( "prefix" ) );
p.setArtifactId( plugin.elementTextTrim( "artifactId" ) );
p.setName( plugin.elementTextTrim( "name" ) );
metadata.addPlugin( p );
}
return metadata;
}
catch ( XMLException e )