mirror of https://github.com/apache/archiva.git
Adding maven repository implementation
This commit is contained in:
parent
1b89266820
commit
3976c3fb23
|
@ -21,9 +21,10 @@ package org.apache.archiva.repository;
|
|||
|
||||
/**
|
||||
* This exception is thrown if a given feature is not supported by the repository.
|
||||
* This is a runtime exception.
|
||||
*
|
||||
*/
|
||||
public class UnsupportedFeatureException extends Exception {
|
||||
public class UnsupportedFeatureException extends RuntimeException {
|
||||
|
||||
public UnsupportedFeatureException() {
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanup
|
|||
private Period retentionTime = Period.ofDays(100);
|
||||
private int retentionCount = 2;
|
||||
|
||||
public ArtifactCleanupFeature() {
|
||||
|
||||
}
|
||||
|
||||
public ArtifactCleanupFeature(boolean deleteReleasedSnapshots, Period retentionTime, int retentionCount) {
|
||||
this.deleteReleasedSnapshots = deleteReleasedSnapshots;
|
||||
this.retentionTime = retentionTime;
|
||||
|
@ -40,7 +44,7 @@ public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanup
|
|||
}
|
||||
|
||||
@Override
|
||||
public ArtifactCleanupFeature getFeature() {
|
||||
public ArtifactCleanupFeature get() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,16 @@ public class IndexCreationFeature implements RepositoryFeature<IndexCreationFeat
|
|||
|
||||
private boolean skipPackedIndexCreation = false;
|
||||
|
||||
public IndexCreationFeature() {
|
||||
|
||||
}
|
||||
|
||||
public IndexCreationFeature(boolean skipPackedIndexCreation) {
|
||||
this.skipPackedIndexCreation = skipPackedIndexCreation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexCreationFeature getFeature() {
|
||||
public IndexCreationFeature get() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature>
|
|||
|
||||
|
||||
@Override
|
||||
public RemoteIndexFeature getFeature() {
|
||||
public RemoteIndexFeature get() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,5 +37,5 @@ public interface RepositoryFeature<T extends RepositoryFeature<T>> {
|
|||
return this.getClass().equals(clazz);
|
||||
}
|
||||
|
||||
T getFeature();
|
||||
T get();
|
||||
}
|
||||
|
|
|
@ -31,13 +31,17 @@ public class StagingRepositoryFeature implements RepositoryFeature<StagingReposi
|
|||
private ManagedRepository stagingRepository = null;
|
||||
private boolean stageRepoNeeded = false;
|
||||
|
||||
public StagingRepositoryFeature() {
|
||||
|
||||
}
|
||||
|
||||
public StagingRepositoryFeature(ManagedRepository stagingRepository, boolean stageRepoNeeded) {
|
||||
this.stagingRepository = stagingRepository;
|
||||
this.stageRepoNeeded = stageRepoNeeded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StagingRepositoryFeature getFeature() {
|
||||
public StagingRepositoryFeature get() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,10 @@ import org.apache.archiva.repository.ReleaseScheme;
|
|||
import org.apache.archiva.repository.RepositoryCapabilities;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.StandardCapabilities;
|
||||
import org.apache.archiva.repository.UnsupportedFeatureException;
|
||||
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RepositoryFeature;
|
||||
import org.apache.archiva.repository.features.StagingRepositoryFeature;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -39,6 +41,9 @@ public class MavenManagedRepository extends AbstractManagedRepository
|
|||
public static final String DEFAULT_LAYOUT = "default";
|
||||
public static final String LEGACY_LAYOUT = "legacy";
|
||||
private ManagedRepositoryContent content;
|
||||
private ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature( );
|
||||
private IndexCreationFeature indexCreationFeature = new IndexCreationFeature( );
|
||||
private StagingRepositoryFeature stagingRepositoryFeature = new StagingRepositoryFeature( );
|
||||
|
||||
private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
|
||||
new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
|
||||
|
@ -53,14 +58,14 @@ public class MavenManagedRepository extends AbstractManagedRepository
|
|||
false
|
||||
);
|
||||
|
||||
public MavenManagedRepository( RepositoryType type, String id, String name )
|
||||
public MavenManagedRepository( String id, String name )
|
||||
{
|
||||
super( type, id, name );
|
||||
super( RepositoryType.MAVEN, id, name );
|
||||
}
|
||||
|
||||
public MavenManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name )
|
||||
public MavenManagedRepository( Locale primaryLocale, String id, String name )
|
||||
{
|
||||
super( primaryLocale, type, id, name );
|
||||
super( primaryLocale, RepositoryType.MAVEN, id, name );
|
||||
}
|
||||
|
||||
protected void setContent(ManagedRepositoryContent content) {
|
||||
|
@ -78,4 +83,30 @@ public class MavenManagedRepository extends AbstractManagedRepository
|
|||
{
|
||||
return CAPABILITIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException
|
||||
{
|
||||
if (ArtifactCleanupFeature.class.equals( clazz ))
|
||||
{
|
||||
return (RepositoryFeature<T>) artifactCleanupFeature;
|
||||
} else if (IndexCreationFeature.class.equals(clazz)) {
|
||||
return (RepositoryFeature<T>) indexCreationFeature;
|
||||
} else if (StagingRepositoryFeature.class.equals(clazz)) {
|
||||
return (RepositoryFeature<T>) stagingRepositoryFeature;
|
||||
} else {
|
||||
throw new UnsupportedFeatureException( );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz )
|
||||
{
|
||||
if (ArtifactCleanupFeature.class.equals(clazz) ||
|
||||
IndexCreationFeature.class.equals(clazz) ||
|
||||
StagingRepositoryFeature.class.equals(clazz)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package org.apache.archiva.repository.maven2;
|
||||
|
||||
import org.apache.archiva.repository.AbstractRemoteRepository;
|
||||
import org.apache.archiva.repository.AbstractRepository;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryCapabilities;
|
||||
import org.apache.archiva.repository.RepositoryCredentials;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.StandardCapabilities;
|
||||
import org.apache.archiva.repository.UnsupportedFeatureException;
|
||||
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RemoteIndexFeature;
|
||||
import org.apache.archiva.repository.features.RepositoryFeature;
|
||||
import org.apache.archiva.repository.features.StagingRepositoryFeature;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -43,6 +40,11 @@ import java.util.Map;
|
|||
public class MavenRemoteRepository extends AbstractRemoteRepository
|
||||
implements RemoteRepository
|
||||
{
|
||||
private ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature( );
|
||||
private IndexCreationFeature indexCreationFeature = new IndexCreationFeature( );
|
||||
private StagingRepositoryFeature stagingRepositoryFeature = new StagingRepositoryFeature( );
|
||||
private RemoteIndexFeature remoteIndexFeature = new RemoteIndexFeature();
|
||||
|
||||
private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
|
||||
new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
|
||||
new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
|
||||
|
@ -56,14 +58,14 @@ public class MavenRemoteRepository extends AbstractRemoteRepository
|
|||
false
|
||||
);
|
||||
|
||||
public MavenRemoteRepository( RepositoryType type, String id, String name )
|
||||
public MavenRemoteRepository( String id, String name )
|
||||
{
|
||||
super( type, id, name );
|
||||
super( RepositoryType.MAVEN, id, name );
|
||||
}
|
||||
|
||||
public MavenRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name )
|
||||
public MavenRemoteRepository( Locale primaryLocale, String id, String name )
|
||||
{
|
||||
super( primaryLocale, type, id, name );
|
||||
super( primaryLocale, RepositoryType.MAVEN, id, name );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,4 +73,33 @@ public class MavenRemoteRepository extends AbstractRemoteRepository
|
|||
{
|
||||
return CAPABILITIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException
|
||||
{
|
||||
if (ArtifactCleanupFeature.class.equals(clazz)) {
|
||||
return (RepositoryFeature<T>) artifactCleanupFeature;
|
||||
} else if (IndexCreationFeature.class.equals(clazz)) {
|
||||
return (RepositoryFeature<T>) indexCreationFeature;
|
||||
} else if (StagingRepositoryFeature.class.equals(clazz)) {
|
||||
return (RepositoryFeature<T>) stagingRepositoryFeature;
|
||||
} else if (RemoteIndexFeature.class.equals( clazz )) {
|
||||
return (RepositoryFeature<T>) remoteIndexFeature;
|
||||
} else {
|
||||
throw new UnsupportedFeatureException( );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz )
|
||||
{
|
||||
if (ArtifactCleanupFeature.class.equals(clazz) ||
|
||||
IndexCreationFeature.class.equals(clazz) ||
|
||||
StagingRepositoryFeature.class.equals(clazz) ||
|
||||
RemoteIndexFeature.class.equals(clazz)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.archiva.repository.ManagedRepository;
|
|||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RepositoryProvider;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.features.StagingRepositoryFeature;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -46,9 +47,10 @@ public class MavenRepositoryProvider implements RepositoryProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration )
|
||||
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration cfg )
|
||||
{
|
||||
MavenManagedRepository repo = new MavenManagedRepository( null, null ,null );
|
||||
MavenManagedRepository repo = new MavenManagedRepository(cfg.getId() ,cfg.getName());
|
||||
StagingRepositoryFeature feature = repo.getFeature( StagingRepositoryFeature.class ).get();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue