/// ***************** End of new generation interface **********************
-
- /**
- * Returns the version reference for the given coordinates.
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version number
- * @return a version reference
- */
- VersionedReference toVersion( String groupId, String artifactId, String version );
-
-
- /**
- * Return the version reference that matches exactly the version string of the artifact
- *
- * @param artifactReference The artifact reference
- * @return the version reference
- */
- VersionedReference toVersion( ArtifactReference artifactReference);
-
-
- /**
- * delete a specified artifact from the repository
- *
- * @param artifactReference
- * @throws ContentNotFoundException
- */
- void deleteArtifact( ArtifactReference artifactReference )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
- /**
- * @param groupId
- * @throws ContentNotFoundException
- * @since 1.4-M3
- */
- void deleteGroupId( String groupId )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
-
- /**
- *
- * @param namespace groupId for maven
- * @param projectId artifactId for maven
- * @throws ContentNotFoundException
- */
- void deleteProject( String namespace, String projectId )
- throws ContentNotFoundException, ContentAccessException;
-
-
- /**
- * Deletes a project
- * @param reference
- */
- void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
-
-
-
-
-
-
- /**
- * <p>
- * Gather up the list of related artifacts to the ArtifactReference provided.
- * This typically includes the pom files, and those things with
- * classifiers (such as doc, source code, test libs, etc...). Even if the classifier
- * is set in the artifact reference, it may return artifacts with different classifiers.
- * </p>
- * <p>
- * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
- * </p>
- *
- * @param reference the reference to work off of.
- * @return the list of ArtifactReferences for related artifacts, if
- * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
- */
- List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
- throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
- /**
- * Returns all artifacts that belong to a given version
- * @param reference the version reference
- * @return the list of artifacts or a empty list
- */
- List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
-
-
/**
* <p>
* Convenience method to get the repository (on disk) root directory.
String getRepoRoot();
- /**
- * Given an {@link ArtifactReference}, return the file reference to the artifact.
- *
- * @param reference the artifact reference to use.
- * @return the relative path to the artifact.
- */
- StorageAsset toFile( VersionedReference reference );
-
-
}
*/
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
-import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentAccessException;
-import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ItemDeleteStatus;
import org.apache.archiva.repository.LayoutException;
{
private ManagedRepository repository;
- @Override
- public VersionedReference toVersion( String groupId, String artifactId, String version )
- {
- return null;
- }
-
- @Override
- public VersionedReference toVersion( ArtifactReference artifactReference )
- {
- return null;
- }
-
@Override
public void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException
{
return null;
}
- @Override
- public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
@Override
public Artifact getArtifact( ItemSelector selector ) throws ContentAccessException
}
- @Override
- public void deleteGroupId( String groupId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
-
- @Override
- public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteProject( ProjectReference reference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
@Override
public String toPath( ContentItem item )
{
return null;
}
- @Override
- public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
- @Override
- public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
@Override
public String getRepoRoot( )
{
this.repository = repo;
}
- @Override
- public StorageAsset toFile( VersionedReference reference )
- {
- return null;
- }
-
@Override
public ArtifactReference toArtifactReference( String path ) throws LayoutException
{
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
-import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.BaseDataItemTypes;
this.repository = repo;
}
- @Override
- public VersionedReference toVersion( String groupId, String artifactId, String version )
- {
- return null;
- }
-
- @Override
- public VersionedReference toVersion( ArtifactReference artifactReference )
- {
- return null;
- }
-
@Override
public <T extends ContentItem> T adaptItem( Class<T> clazz, ContentItem item ) throws LayoutException
{
return null;
}
- @Override
- public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteGroupId( String groupId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteProject( ProjectReference reference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
@Override
public String toPath( ContentItem item )
{
return repository.getId();
}
- @Override
- public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
- @Override
- public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
@Override
public String getRepoRoot( )
{
this.repository = repo;
}
- @Override
- public StorageAsset toFile( VersionedReference reference )
- {
- return null;
- }
-
private Map<ArtifactReference, String> refs = new HashMap<>();
@Override
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
-import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.content.BaseDataItemTypes;
this.fsStorage = repo;
}
- @Override
- public VersionedReference toVersion( String groupId, String artifactId, String version )
- {
- return null;
- }
-
- @Override
- public VersionedReference toVersion( ArtifactReference artifactReference )
- {
- return null;
- }
-
@Override
public <T extends ContentItem> T adaptItem( Class<T> clazz, ContentItem item ) throws LayoutException
{
}
}
- @Override
- public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteGroupId( String groupId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
- public void deleteProject( ProjectReference reference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
@Override
public String toPath( ContentItem item )
{
return repository.getId();
}
- @Override
- public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
- @Override
- public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- return null;
- }
-
@Override
public String getRepoRoot( )
{
this.repository = repo;
}
- @Override
- public StorageAsset toFile( VersionedReference reference )
- {
- return null;
- }
-
private Map<ArtifactReference, String> refs = new HashMap<>();
@Override
import org.apache.archiva.metadata.maven.MavenMetadataReader;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentAccessException;
import org.apache.archiva.repository.ContentNotFoundException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Matcher;
/// ************* End of new generation interface ******************
- /**
- * Returns a version reference from the coordinates
- *
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version
- * @return the versioned reference object
- */
- @Override
- public VersionedReference toVersion( String groupId, String artifactId, String version )
- {
- return new VersionedReference( ).groupId( groupId ).artifactId( artifactId ).version( version );
- }
-
- /**
- * Return the version the artifact is part of
- *
- * @param artifactReference
- * @return
- */
- public VersionedReference toVersion( ArtifactReference artifactReference )
- {
- return toVersion( artifactReference.getGroupId( ), artifactReference.getArtifactId( ), artifactReference.getVersion( ) );
- }
-
@Override
public String toPath( ContentItem item ) {
return item.getAsset( ).getPath( );
}
- @Override
- public void deleteProject( ProjectReference ref )
- throws ContentNotFoundException, ContentAccessException
- {
- final String path = toPath( ref );
- final Path deleteTarget = getRepoDir( ).resolve( path );
- if ( !Files.exists( deleteTarget ) )
- {
- log.warn( "Project path for repository {} does not exist: {}", getId( ), deleteTarget );
- throw new ContentNotFoundException( "Project not found for repository " + getId( ) + ": " + path );
- }
- if ( Files.isDirectory( deleteTarget ) )
- {
- try
- {
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget );
- }
- catch ( IOException e )
- {
- log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e );
- throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e );
- }
- }
- else
- {
- log.warn( "Project path for repository {} is not a directory {}", getId( ), deleteTarget );
- throw new ContentNotFoundException( "Project path for repository " + getId( ) + " is not directory: " + path );
- }
-
- }
-
- @Override
- public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException
- {
- this.deleteProject( new ProjectReference( ).groupId( namespace ).artifactId( projectId ) );
- }
-
- @Override
- public void deleteArtifact( ArtifactReference ref ) throws ContentNotFoundException, ContentAccessException
- {
- final String path = toPath( ref );
- final Path repoDir = getRepoDir( );
- Path deleteTarget = repoDir.resolve( path );
- if ( Files.exists( deleteTarget ) )
- {
- try
- {
- if ( Files.isDirectory( deleteTarget ) )
- {
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget );
- }
- else
- {
- Files.delete( deleteTarget );
- }
- }
- catch ( IOException e )
- {
- log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e );
- throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e );
- }
- }
- else
- {
- log.warn( "Artifact path for repository {} does not exist: {}", getId( ), deleteTarget );
- throw new ContentNotFoundException( "Artifact not found for repository " + getId( ) + ": " + path );
- }
-
- }
-
- @Override
- public void deleteGroupId( String groupId )
- throws ContentNotFoundException, ContentAccessException
- {
- final String path = toPath( groupId );
- final Path deleteTarget = getRepoDir( ).resolve( path );
- if ( !Files.exists( deleteTarget ) )
- {
- log.warn( "Namespace path for repository {} does not exist: {}", getId( ), deleteTarget );
- throw new ContentNotFoundException( "Namespace not found for repository " + getId( ) + ": " + path );
- }
- if ( Files.isDirectory( deleteTarget ) )
- {
- try
- {
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget );
- }
- catch ( IOException e )
- {
- log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e );
- throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e );
- }
- }
- else
- {
- log.warn( "Namespace path for repository {} is not a directory {}", getId( ), deleteTarget );
- throw new ContentNotFoundException( "Namespace path for repository " + getId( ) + " is not directory: " + path );
-
- }
- }
-
@Override
public String getId( )
{
return repository.getId( );
}
- @Override
- public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
- throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- StorageAsset artifactDir = toFile( reference );
- if ( !artifactDir.exists( ) )
- {
- throw new ContentNotFoundException(
- "Unable to get related artifacts using a non-existant directory: " + artifactDir.getPath( ) );
- }
-
- if ( !artifactDir.isContainer( ) )
- {
- throw new ContentNotFoundException(
- "Unable to get related artifacts using a non-directory: " + artifactDir.getPath( ) );
- }
-
- // First gather up the versions found as artifacts in the managed repository.
-
- try ( Stream<? extends StorageAsset> stream = artifactDir.list( ).stream( ) )
- {
- return stream.filter( asset -> !asset.isContainer( ) ).map( path -> {
- try
- {
- ArtifactReference artifact = toArtifactReference( path.getPath( ) );
- if ( artifact.getGroupId( ).equals( reference.getGroupId( ) ) && artifact.getArtifactId( ).equals(
- reference.getArtifactId( ) ) && artifact.getVersion( ).equals( reference.getVersion( ) ) )
- {
- return artifact;
- }
- else
- {
- return null;
- }
- }
- catch ( LayoutException e )
- {
- log.debug( "Not processing file that is not an artifact: {}", e.getMessage( ) );
- return null;
- }
- } ).filter( Objects::nonNull ).collect( Collectors.toList( ) );
- }
- catch ( RuntimeException e )
- {
- Throwable cause = e.getCause( );
- if ( cause != null )
- {
- if ( cause instanceof LayoutException )
- {
- throw (LayoutException) cause;
- }
- else
- {
- throw new ContentAccessException( cause.getMessage( ), cause );
- }
- }
- else
- {
- throw new ContentAccessException( e.getMessage( ), e );
- }
- }
- }
-
/*
* Create the filter for various combinations of classifier and type
*/
}
- @Override
- public StorageAsset toFile( VersionedReference reference )
- {
- return repository.getAsset( toPath( reference ) );
- }
-
/**
* Get the first Artifact found in the provided VersionedReference location.
*
.map( this::toArtifactRef );
}
- public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException
- {
- try ( Stream<ArtifactReference> stream = newArtifactStream( reference ) )
- {
- return stream.collect( Collectors.toList( ) );
- }
- catch ( IOException e )
- {
- String path = toPath( reference );
- log.error( "Could not read directory from repository {} - {}: ", getId( ), path, e.getMessage( ), e );
- throw new ContentAccessException( "Could not read path from repository " + getId( ) + ": " + path, e );
-
- }
- }
-
private boolean hasArtifact( VersionedReference reference )
{
}
- @Test
- public void testDeleteArtifactWithType() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException
- {
- Path deleteRepo = setupRepoCopy( "delete-repository", "delete-repository-2" );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
- ArtifactReference ref = new ArtifactReference( );
- ref.setGroupId( "org.apache.maven" );
- ref.setArtifactId( "samplejar" );
- ref.setVersion( "1.0" );
- ref.setType( "jar" );
-
- repoContent.deleteArtifact( ref );
-
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
-
- }
-
-
- @Test
- public void testDeleteArtifactWithClassifier() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException
- {
- Path deleteRepo = setupRepoCopy( "default-repository", "default-repository-2" );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
- ArtifactReference ref = new ArtifactReference( );
- ref.setGroupId( "org.apache.maven" );
- ref.setArtifactId( "samplejar" );
- ref.setVersion( "1.0" );
- ref.setClassifier( "source" );
- ref.setType( "jar" );
-
- repoContent.deleteArtifact( ref );
-
- assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
- }
-
- @Test
- public void testDeleteArtifactWithoutType() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException
- {
- Path deleteRepo = setupRepoCopy( "default-repository", "default-repository-2" );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
- ArtifactReference ref = new ArtifactReference( );
- ref.setGroupId( "org.apache.maven" );
- ref.setArtifactId( "samplejar" );
- ref.setVersion( "1.0" );
-
- repoContent.deleteArtifact( ref );
-
- assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar" ) ) );
-
- }
-
-
- @Test
- public void testDeleteProject() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException
- {
- Path deleteRepo = setupRepoCopy( "delete-repository", "delete-repository-2" );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) );
- assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) );
-
- ProjectReference ref = new ProjectReference( ).groupId( "org.apache.maven" ).artifactId( "samplejar" );
-
- repoContent.deleteProject( ref );
-
- assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0" ) ) );
-
- }
@Test
public void testGetArtifactStreamWithVersionSelector() {
boolean snapshotVersion =
VersionUtil.isSnapshot( artifact.getVersion() ) | VersionUtil.isGenericSnapshot( artifact.getVersion() );
+ String baseVersion = VersionUtil.getBaseVersion( artifact.getVersion( ) );
RepositorySession repositorySession = null;
try
ArchivaItemSelector versionSelector = ArchivaItemSelector.builder( ).withNamespace( artifact.getGroupId( ) )
.withProjectId( artifact.getArtifactId( ) )
- .withVersion( artifact.getVersion( ) ).build( );
+ .withVersion( baseVersion ).build( );
Version version1 = layout.getVersion( versionSelector );
String path = repository.toPath( version1 );
ArchivaItemSelector selector = ArchivaItemSelector.builder( )
.withNamespace( artifact.getGroupId( ) )
.withProjectId( artifact.getArtifactId( ) )
- .withVersion( artifact.getVersion( ) )
+ .withVersion( baseVersion )
.withClassifier( artifact.getClassifier( ) )
.withArtifactId( artifact.getArtifactId( ) )
.withType( artifact.getType( ) )
else
{
// We are deleting all version related artifacts for a snapshot version
- VersionedReference versionRef = layout.toVersion( artifactReference );
- List<ArtifactReference> related = layout.getRelatedArtifacts( versionRef );
- log.debug( "related: {}", related );
- for ( ArtifactReference artifactRef : related )
- {
+ for ( org.apache.archiva.repository.content.Artifact delArtifact : layout.getArtifacts( selector )) {
try
{
- layout.deleteArtifact( artifactRef );
- } catch (ContentNotFoundException e) {
- log.warn( "Artifact that should be deleted, was not found: {}", artifactRef );
+ repository.deleteItem( delArtifact );
+ }
+ catch ( ItemNotFoundException e )
+ {
+ log.warn( "Artifact that should be deleted, was not found: {}", delArtifact );
}
+
}
StorageAsset metadataFile = getMetadata( repo, targetPath.getPath() );
ArchivaRepositoryMetadata metadata = getMetadata( repository.getRepository().getType(), metadataFile );
-
updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, artifact );
}
}
if ( snapshotVersion )
{
- String baseVersion = VersionUtil.getBaseVersion( artifact.getVersion() );
artifacts =
metadataRepository.getArtifacts(repositorySession , repositoryId, artifact.getGroupId(),
artifact.getArtifactId(), baseVersion );