implements the method with metadata-store-file

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1354120 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-06-26 17:25:08 +00:00
parent 9c6b8dba00
commit f68a05a499

View File

@ -600,8 +600,43 @@ public List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, Strin
public void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
throws MetadataRepositoryException
{
// FIXME implement this
throw new UnsupportedOperationException();
File directory = new File( getDirectory( artifactMetadata.getRepositoryId() ),
artifactMetadata.getNamespace() + "/" + artifactMetadata.getProject() + "/"
+ baseVersion );
Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY );
String id = artifactMetadata.getId();
properties.remove( "artifact:updated:" + id );
properties.remove( "artifact:whenGathered:" + id );
properties.remove( "artifact:size:" + id );
properties.remove( "artifact:md5:" + id );
properties.remove( "artifact:sha1:" + id );
properties.remove( "artifact:version:" + id );
properties.remove( "artifact:facetIds:" + id );
String prefix = "artifact:facet:" + id + ":";
for ( Object key : new ArrayList<Object>( properties.keySet() ) )
{
String property = (String) key;
if ( property.startsWith( prefix ) )
{
properties.remove( property );
}
}
try
{
writeProperties( properties, directory, PROJECT_VERSION_METADATA_KEY );
}
catch ( IOException e )
{
// TODO
log.error( e.getMessage(), e );
}
}
public void removeArtifact( String repoId, String namespace, String project, String version, String id )
@ -645,6 +680,7 @@ public void removeArtifact( String repoId, String namespace, String project, Str
/**
* FIXME implements this !!!!
*
* @param repositoryId
* @param namespace
* @param project