@@ -1,42 +0,0 @@ | |||
package org.apache.archiva.repository.content; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.LayoutException; | |||
/** | |||
* PathParser interface. | |||
*/ | |||
public interface PathParser | |||
{ | |||
/** | |||
* Return a item selector for the given path. | |||
* | |||
* @param path the path relative to the repository | |||
* @return a item selector instance | |||
* @throws LayoutException if the path does not reference a valid item | |||
*/ | |||
ItemSelector toItemSelector( String path ) throws LayoutException; | |||
} |
@@ -256,6 +256,12 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout | |||
return false; | |||
} | |||
@Override | |||
public List<Class<? extends ManagedRepositoryContentLayout>> getSupportedLayouts( ) | |||
{ | |||
return null; | |||
} | |||
@Override | |||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException | |||
{ |
@@ -267,6 +267,12 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout | |||
return false; | |||
} | |||
@Override | |||
public List<Class<? extends ManagedRepositoryContentLayout>> getSupportedLayouts( ) | |||
{ | |||
return null; | |||
} | |||
@Override | |||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException | |||
{ |
@@ -292,6 +292,12 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout | |||
return true; | |||
} | |||
@Override | |||
public List<Class<? extends ManagedRepositoryContentLayout>> getSupportedLayouts( ) | |||
{ | |||
return null; | |||
} | |||
@Override | |||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException | |||
{ |
@@ -19,9 +19,11 @@ package org.apache.archiva.repository.maven.content; | |||
*/ | |||
import org.apache.archiva.common.utils.VersionUtil; | |||
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet; | |||
import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.repository.content.base.ArchivaItemSelector; | |||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; | |||
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator; | |||
import org.apache.archiva.model.ArchivaArtifact; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.model.ProjectReference; | |||
@@ -29,7 +31,6 @@ import org.apache.archiva.model.VersionedReference; | |||
import org.apache.archiva.repository.LayoutException; | |||
import org.apache.archiva.repository.RepositoryContent; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
@@ -53,24 +54,21 @@ public abstract class AbstractDefaultRepositoryContent implements RepositoryCont | |||
protected static final char ARTIFACT_SEPARATOR = '-'; | |||
private RepositoryPathTranslator pathTranslator = new Maven2RepositoryPathTranslator(); | |||
private RepositoryPathTranslator pathTranslator; | |||
private List<? extends ArtifactMappingProvider> artifactMappingProviders; | |||
private PathParser defaultPathParser = new DefaultPathParser(); | |||
PathParser getPathParser() { | |||
return defaultPathParser; | |||
AbstractDefaultRepositoryContent() { | |||
} | |||
public RepositoryPathTranslator getPathTranslator( ) | |||
{ | |||
return pathTranslator; | |||
} | |||
/** | |||
* | |||
*/ | |||
protected List<? extends ArtifactMappingProvider> artifactMappingProviders; | |||
AbstractDefaultRepositoryContent(List<? extends ArtifactMappingProvider> artifactMappingProviders) { | |||
this.artifactMappingProviders = artifactMappingProviders; | |||
public void setPathTranslator( RepositoryPathTranslator pathTranslator ) | |||
{ | |||
this.pathTranslator = pathTranslator; | |||
} | |||
public void setArtifactMappingProviders(List<? extends ArtifactMappingProvider> artifactMappingProviders) { | |||
@@ -80,7 +78,32 @@ public abstract class AbstractDefaultRepositoryContent implements RepositoryCont | |||
@Override | |||
public ItemSelector toItemSelector( String path ) throws LayoutException | |||
{ | |||
return defaultPathParser.toItemSelector( path ); | |||
if ( StringUtils.isBlank( path ) ) | |||
{ | |||
throw new LayoutException( "Unable to convert blank path." ); | |||
} | |||
try | |||
{ | |||
ArtifactMetadata metadata = pathTranslator.getArtifactForPath( null, path ); | |||
ArchivaItemSelector.Builder builder = ArchivaItemSelector.builder( ).withNamespace( metadata.getNamespace( ) ) | |||
.withProjectId( metadata.getProject( ) ) | |||
.withVersion( metadata.getProjectVersion( ) ) | |||
.withArtifactId( metadata.getProject( ) ) | |||
.withArtifactVersion( metadata.getVersion( ) ); | |||
MavenArtifactFacet facet = (MavenArtifactFacet) metadata.getFacet( MavenArtifactFacet.FACET_ID ); | |||
if ( facet != null ) | |||
{ | |||
builder.withClassifier( facet.getClassifier() ); | |||
builder.withType( facet.getType() ); | |||
} | |||
return builder.build( ); | |||
} | |||
catch ( IllegalArgumentException e ) | |||
{ | |||
throw new LayoutException( e.getMessage(), e ); | |||
} | |||
} | |||
public String toPath ( ProjectReference reference) { |
@@ -1,84 +0,0 @@ | |||
package org.apache.archiva.repository.maven.content; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; | |||
import org.apache.archiva.repository.maven.metadata.storage.DefaultArtifactMappingProvider; | |||
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator; | |||
import org.apache.archiva.repository.LayoutException; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.archiva.repository.content.base.ArchivaItemSelector; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Service; | |||
import java.util.Collections; | |||
/** | |||
* DefaultPathParser is a parser for maven 2 (default layout) paths to ArtifactReference. | |||
* | |||
* TODO: remove in favour of path translator, this is just delegating for the most part, but won't accommodate other | |||
* extensions like NPanday | |||
* | |||
* | |||
*/ | |||
@Service( "pathParser#default" ) | |||
public class DefaultPathParser | |||
implements PathParser | |||
{ | |||
private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: "; | |||
private RepositoryPathTranslator pathTranslator = new Maven2RepositoryPathTranslator( | |||
Collections.<ArtifactMappingProvider>singletonList( new DefaultArtifactMappingProvider() ) ); | |||
@Override | |||
public ItemSelector toItemSelector( String path ) throws LayoutException | |||
{ | |||
if ( StringUtils.isBlank( path ) ) | |||
{ | |||
throw new LayoutException( "Unable to convert blank path." ); | |||
} | |||
try | |||
{ | |||
ArtifactMetadata metadata = pathTranslator.getArtifactForPath( null, path ); | |||
ArchivaItemSelector.Builder builder = ArchivaItemSelector.builder( ).withNamespace( metadata.getNamespace( ) ) | |||
.withProjectId( metadata.getProject( ) ) | |||
.withVersion( metadata.getProjectVersion( ) ) | |||
.withArtifactId( metadata.getProject( ) ) | |||
.withArtifactVersion( metadata.getVersion( ) ); | |||
MavenArtifactFacet facet = (MavenArtifactFacet) metadata.getFacet( MavenArtifactFacet.FACET_ID ); | |||
if ( facet != null ) | |||
{ | |||
builder.withClassifier( facet.getClassifier() ); | |||
builder.withType( facet.getType() ); | |||
} | |||
return builder.build( ); | |||
} | |||
catch ( IllegalArgumentException e ) | |||
{ | |||
throw new LayoutException( e.getMessage(), e ); | |||
} | |||
} | |||
} |
@@ -99,10 +99,6 @@ public class ManagedDefaultRepositoryContent | |||
private FileLockManager lockManager; | |||
@Inject | |||
@Named( "repositoryPathTranslator#maven2" ) | |||
private RepositoryPathTranslator pathTranslator; | |||
@Inject | |||
@Named( "metadataReader#maven" ) | |||
MavenMetadataReader metadataReader; | |||
@@ -133,26 +129,17 @@ public class ManagedDefaultRepositoryContent | |||
public ManagedDefaultRepositoryContent( ) | |||
{ | |||
super( Collections.singletonList( new DefaultArtifactMappingProvider( ) ) ); | |||
super( ); | |||
} | |||
public ManagedDefaultRepositoryContent( ManagedRepository repository, FileTypes fileTypes, FileLockManager lockManager ) | |||
{ | |||
super( Collections.singletonList( new DefaultArtifactMappingProvider( ) ) ); | |||
super( ); | |||
setFileTypes( fileTypes ); | |||
this.lockManager = lockManager; | |||
setRepository( repository ); | |||
} | |||
public ManagedDefaultRepositoryContent( ManagedRepository repository, List<? extends ArtifactMappingProvider> artifactMappingProviders, FileTypes fileTypes, FileLockManager lockManager ) | |||
{ | |||
super( artifactMappingProviders == null ? Collections.singletonList( new DefaultArtifactMappingProvider( ) ) : artifactMappingProviders ); | |||
setFileTypes( fileTypes ); | |||
this.lockManager = lockManager; | |||
setRepository( repository ); | |||
} | |||
private StorageAsset getAssetByPath( String assetPath ) | |||
{ | |||
return getStorage( ).getAsset( assetPath ); |
@@ -20,6 +20,7 @@ package org.apache.archiva.repository.maven.content; | |||
import org.apache.archiva.common.filelock.FileLockManager; | |||
import org.apache.archiva.configuration.FileTypes; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; | |||
import org.apache.archiva.repository.ManagedRepository; | |||
@@ -31,6 +32,7 @@ import org.apache.archiva.repository.RepositoryContent; | |||
import org.apache.archiva.repository.RepositoryContentProvider; | |||
import org.apache.archiva.repository.RepositoryException; | |||
import org.apache.archiva.repository.RepositoryType; | |||
import org.apache.maven.model.path.PathTranslator; | |||
import org.springframework.stereotype.Service; | |||
import javax.inject.Inject; | |||
@@ -61,6 +63,10 @@ public class MavenContentProvider implements RepositoryContentProvider | |||
@Named("MavenContentHelper") | |||
MavenContentHelper mavenContentHelper; | |||
@Inject | |||
@Named("repositoryPathTranslator#maven2") | |||
RepositoryPathTranslator pathTranslator; | |||
private static final Set<RepositoryType> REPOSITORY_TYPES = new HashSet<>( ); | |||
static { | |||
REPOSITORY_TYPES.add(RepositoryType.MAVEN); | |||
@@ -93,8 +99,10 @@ public class MavenContentProvider implements RepositoryContentProvider | |||
if (!supportsLayout( repository.getLayout() )) { | |||
throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); | |||
} | |||
RemoteDefaultRepositoryContent content = new RemoteDefaultRepositoryContent(artifactMappingProviders); | |||
RemoteDefaultRepositoryContent content = new RemoteDefaultRepositoryContent(); | |||
content.setRepository( repository ); | |||
content.setPathTranslator( pathTranslator ); | |||
content.setArtifactMappingProviders( artifactMappingProviders ); | |||
return content; | |||
} | |||
@@ -107,8 +115,10 @@ public class MavenContentProvider implements RepositoryContentProvider | |||
if (!supportsLayout( repository.getLayout() )) { | |||
throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); | |||
} | |||
ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, filetypes ,fileLockManager); | |||
ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(repository, filetypes ,fileLockManager); | |||
content.setMavenContentHelper( mavenContentHelper ); | |||
content.setPathTranslator( pathTranslator ); | |||
content.setArtifactMappingProviders( artifactMappingProviders ); | |||
return content; | |||
} | |||
@@ -20,7 +20,6 @@ package org.apache.archiva.repository.maven.content; | |||
import org.apache.archiva.repository.*; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.archiva.repository.features.RepositoryFeature; | |||
import org.apache.archiva.repository.metadata.base.MetadataTools; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -31,8 +30,6 @@ import org.apache.commons.lang3.StringUtils; | |||
*/ | |||
public class MavenRepositoryRequestInfo implements RepositoryRequestInfo | |||
{ | |||
private PathParser defaultPathParser = new DefaultPathParser(); | |||
ManagedRepository repository; | |||
public MavenRepositoryRequestInfo(ManagedRepository repository) |
@@ -37,8 +37,8 @@ public class RemoteDefaultRepositoryContent | |||
private RemoteRepository repository; | |||
public RemoteDefaultRepositoryContent( List<? extends ArtifactMappingProvider> artifactMappingProviders ) { | |||
super(artifactMappingProviders); | |||
public RemoteDefaultRepositoryContent( ) { | |||
super(); | |||
} | |||
@Override |
@@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; | |||
import javax.annotation.PostConstruct; | |||
import javax.inject.Inject; | |||
import java.lang.invoke.MethodHandle; | |||
import java.util.List; | |||
import java.util.regex.Matcher; | |||
import java.util.regex.Pattern; | |||
@@ -42,7 +43,7 @@ public class Maven2RepositoryPathTranslator | |||
implements RepositoryPathTranslator | |||
{ | |||
private Logger log = LoggerFactory.getLogger( getClass() ); | |||
private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryPathTranslator.class ); | |||
private static final char GROUP_SEPARATOR = '.'; | |||
@@ -63,6 +64,18 @@ public class Maven2RepositoryPathTranslator | |||
// noop | |||
} | |||
public List<ArtifactMappingProvider> getArtifactMappingProviders( ) | |||
{ | |||
return artifactMappingProviders; | |||
} | |||
public void setArtifactMappingProviders( List<ArtifactMappingProvider> artifactMappingProviders ) | |||
{ | |||
this.artifactMappingProviders = artifactMappingProviders; | |||
} | |||
@PostConstruct | |||
public void initialize() | |||
{ |
@@ -28,7 +28,13 @@ import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.model.ProjectMetadata; | |||
import org.apache.archiva.metadata.model.ProjectVersionMetadata; | |||
import org.apache.archiva.metadata.model.facets.RepositoryProblemFacet; | |||
import org.apache.archiva.metadata.repository.storage.*; | |||
import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; | |||
import org.apache.archiva.metadata.repository.storage.RelocationException; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryStorage; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException; | |||
import org.apache.archiva.model.ArchivaRepositoryMetadata; | |||
import org.apache.archiva.model.SnapshotVersion; | |||
import org.apache.archiva.policies.ProxyDownloadException; | |||
@@ -37,19 +43,39 @@ import org.apache.archiva.proxy.maven.WagonFactory; | |||
import org.apache.archiva.proxy.model.NetworkProxy; | |||
import org.apache.archiva.proxy.model.ProxyConnector; | |||
import org.apache.archiva.proxy.model.RepositoryProxyHandler; | |||
import org.apache.archiva.repository.*; | |||
import org.apache.archiva.repository.BaseRepositoryContentLayout; | |||
import org.apache.archiva.repository.LayoutException; | |||
import org.apache.archiva.repository.ManagedRepository; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.ReleaseScheme; | |||
import org.apache.archiva.repository.RemoteRepository; | |||
import org.apache.archiva.repository.RepositoryRegistry; | |||
import org.apache.archiva.repository.RepositoryType; | |||
import org.apache.archiva.repository.content.Artifact; | |||
import org.apache.archiva.repository.content.ContentItem; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.archiva.repository.content.base.ArchivaItemSelector; | |||
import org.apache.archiva.repository.maven.MavenSystemManager; | |||
import org.apache.archiva.repository.metadata.RepositoryMetadataException; | |||
import org.apache.archiva.repository.storage.StorageAsset; | |||
import org.apache.commons.lang3.ArrayUtils; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.maven.model.*; | |||
import org.apache.maven.model.building.*; | |||
import org.apache.maven.model.CiManagement; | |||
import org.apache.maven.model.Dependency; | |||
import org.apache.maven.model.DistributionManagement; | |||
import org.apache.maven.model.IssueManagement; | |||
import org.apache.maven.model.License; | |||
import org.apache.maven.model.MailingList; | |||
import org.apache.maven.model.Model; | |||
import org.apache.maven.model.Organization; | |||
import org.apache.maven.model.Relocation; | |||
import org.apache.maven.model.Scm; | |||
import org.apache.maven.model.building.DefaultModelBuilderFactory; | |||
import org.apache.maven.model.building.DefaultModelBuildingRequest; | |||
import org.apache.maven.model.building.ModelBuilder; | |||
import org.apache.maven.model.building.ModelBuildingException; | |||
import org.apache.maven.model.building.ModelBuildingRequest; | |||
import org.apache.maven.model.building.ModelProblem; | |||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader; | |||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | |||
import org.slf4j.Logger; | |||
@@ -68,7 +94,14 @@ import java.nio.charset.Charset; | |||
import java.nio.file.NoSuchFileException; | |||
import java.time.ZoneId; | |||
import java.time.ZonedDateTime; | |||
import java.util.*; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
@@ -110,10 +143,6 @@ public class Maven2RepositoryStorage | |||
@Inject | |||
private ApplicationContext applicationContext; | |||
@Inject | |||
@Named("pathParser#default") | |||
private PathParser pathParser; | |||
@Inject | |||
private ProxyRegistry proxyRegistry; | |||
@@ -962,12 +991,4 @@ public class Maven2RepositoryStorage | |||
} | |||
} | |||
public PathParser getPathParser() { | |||
return pathParser; | |||
} | |||
public void setPathParser(PathParser pathParser) { | |||
this.pathParser = pathParser; | |||
} | |||
} |
@@ -1,592 +0,0 @@ | |||
package org.apache.archiva.repository.maven.content; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.repository.LayoutException; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.springframework.test.context.ContextConfiguration; | |||
import static org.junit.Assert.*; | |||
/** | |||
* DefaultPathParserTest | |||
* | |||
* TODO: move to path translator tests | |||
* | |||
* | |||
*/ | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) | |||
public class DefaultPathParserTest | |||
{ | |||
private PathParser parser = new DefaultPathParser(); | |||
@Test | |||
public void testBadPathMissingType() | |||
{ | |||
// TODO: should we allow this instead? | |||
assertBadPath( "invalid/invalid/1/invalid-1", "missing type" ); | |||
} | |||
@Test | |||
public void testBadPathReleaseInSnapshotDir() | |||
{ | |||
assertBadPath( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", | |||
"non snapshot artifact inside of a snapshot dir" ); | |||
} | |||
@Test | |||
public void testBadPathTimestampedSnapshotNotInSnapshotDir() | |||
{ | |||
assertBadPath( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar", | |||
"Timestamped Snapshot artifact not inside of an Snapshot dir" ); | |||
} | |||
@Test | |||
public void testBadPathTooShort() | |||
{ | |||
assertBadPath( "invalid/invalid-1.0.jar", "path is too short" ); | |||
} | |||
@Test | |||
public void testBadPathVersionMismatchA() | |||
{ | |||
assertBadPath( "invalid/invalid/1.0/invalid-2.0.jar", "version mismatch between path and artifact" ); | |||
} | |||
@Test | |||
public void testBadPathVersionMismatchB() | |||
{ | |||
assertBadPath( "invalid/invalid/1.0/invalid-1.0b.jar", "version mismatch between path and artifact" ); | |||
} | |||
@Test | |||
public void testBadPathWrongArtifactId() | |||
{ | |||
assertBadPath( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar", | |||
"wrong artifact id" ); | |||
} | |||
/** | |||
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error | |||
*/ | |||
@Test | |||
public void testGoodButDualExtensions() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.project"; | |||
String artifactId = "example-presentation"; | |||
String version = "3.2"; | |||
String artifactVersion = "3.2"; | |||
String classifier = null; | |||
String type = "xml.zip"; | |||
String path = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodButDualExtensionsWithClassifier() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.project"; | |||
String artifactId = "example-presentation"; | |||
String version = "3.2"; | |||
String artifactVersion = "3.2"; | |||
String classifier = "extras"; | |||
String type = "xml.zip"; | |||
String path = "org/project/example-presentation/3.2/example-presentation-3.2-extras.xml.zip"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodButDualExtensionsTarGz() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.project"; | |||
String artifactId = "example-distribution"; | |||
String version = "1.3"; | |||
String artifactVersion = "1.3"; | |||
String classifier = null; | |||
String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2 | |||
String path = "org/project/example-distribution/1.3/example-distribution-1.3.tar.gz"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodButDualExtensionsTarGzAndClassifier() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.project"; | |||
String artifactId = "example-distribution"; | |||
String version = "1.3"; | |||
String artifactVersion = "1.3"; | |||
String classifier = "bin"; | |||
String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2 | |||
String path = "org/project/example-distribution/1.3/example-distribution-1.3-bin.tar.gz"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecGanymedSsh2() | |||
throws LayoutException | |||
{ | |||
String groupId = "ch.ethz.ganymed"; | |||
String artifactId = "ganymed-ssh2"; | |||
String version = "build210"; | |||
String artifactVersion = "build210"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxComm() | |||
throws LayoutException | |||
{ | |||
String groupId = "javax"; | |||
String artifactId = "comm"; | |||
String version = "3.0-u1"; | |||
String artifactVersion = "3.0-u1"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "javax/comm/3.0-u1/comm-3.0-u1.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* Test the ejb-client type spec. | |||
* Type specs are not a 1 to 1 map to the extension. | |||
* This tests that effect. | |||
* @throws LayoutException | |||
*/ | |||
/* TODO: Re-enabled in the future. | |||
public void testGoodFooEjbClient() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo"; | |||
String artifactId = "foo-client"; | |||
String version = "1.0"; | |||
String classifier = null; | |||
String type = "ejb-client"; // oddball type-spec (should result in jar extension) | |||
String path = "com/foo/foo-client/1.0/foo-client-1.0.jar"; | |||
assertLayout( path, groupId, artifactId, version, classifier, type ); | |||
} | |||
*/ | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxPersistence() | |||
throws LayoutException | |||
{ | |||
String groupId = "javax.persistence"; | |||
String artifactId = "ejb"; | |||
String version = "3.0-public_review"; | |||
String artifactVersion = "3.0-public_review"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "javax/persistence/ejb/3.0-public_review/ejb-3.0-public_review.jar"; | |||
/* | |||
* The version id of "public_review" can cause problems. is it part of | |||
* the version spec? or the classifier? | |||
* Since the path spec below shows it in the path, then it is really | |||
* part of the version spec. | |||
*/ | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodComFooTool() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo"; | |||
String artifactId = "foo-tool"; | |||
String version = "1.0"; | |||
String artifactVersion = "1.0"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "com/foo/foo-tool/1.0/foo-tool-1.0.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodCommonsLang() | |||
throws LayoutException | |||
{ | |||
String groupId = "commons-lang"; | |||
String artifactId = "commons-lang"; | |||
String version = "2.1"; | |||
String artifactVersion = "2.1"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testWindowsPathSeparator() | |||
throws LayoutException | |||
{ | |||
String groupId = "commons-lang"; | |||
String artifactId = "commons-lang"; | |||
String version = "2.1"; | |||
String artifactVersion = "2.1"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = "commons-lang\\commons-lang/2.1\\commons-lang-2.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-486] Can not deploy artifact test.maven-arch:test-arch due to "No ArtifactID Detected" | |||
*/ | |||
@Test | |||
public void testGoodDashedArtifactId() | |||
throws LayoutException | |||
{ | |||
String groupId = "test.maven-arch"; | |||
String artifactId = "test-arch"; | |||
String version = "2.0.3-SNAPSHOT"; | |||
String artifactVersion = "2.0.3-SNAPSHOT"; | |||
String classifier = null; | |||
String type = "pom"; | |||
String path = "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.pom"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* It may seem odd, but this is a valid artifact. | |||
*/ | |||
@Test | |||
public void testGoodDotNotationArtifactId() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.company.department"; | |||
String artifactId = "com.company.department"; | |||
String version = "0.2"; | |||
String artifactVersion = "0.2"; | |||
String classifier = null; | |||
String type = "pom"; | |||
String path = "com/company/department/com.company.department/0.2/com.company.department-0.2.pom"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* It may seem odd, but this is a valid artifact. | |||
*/ | |||
@Test | |||
public void testGoodDotNotationSameGroupIdAndArtifactId() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.company.department"; | |||
String artifactId = "com.company.department.project"; | |||
String version = "0.3"; | |||
String artifactVersion = "0.3"; | |||
String classifier = null; | |||
String type = "pom"; | |||
String path = | |||
"com/company/department/com.company.department.project/0.3/com.company.department.project-0.3.pom"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* Test the classifier, and java-source type spec. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodFooLibSources() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo.lib"; | |||
String artifactId = "foo-lib"; | |||
String version = "2.1-alpha-1"; | |||
String artifactVersion = "2.1-alpha-1"; | |||
String classifier = "sources"; | |||
String type = "java-source"; // oddball type-spec (should result in jar extension) | |||
String path = "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodSnapshotMavenTest() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.apache.archiva.test"; | |||
String artifactId = "redonkulous"; | |||
String version = "3.1-beta-1-SNAPSHOT"; | |||
String artifactVersion = "3.1-beta-1-20050831.101112-42"; | |||
String classifier = null; | |||
String type = "jar"; | |||
String path = | |||
"org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testGoodLongSnapshotMavenTest() | |||
throws LayoutException | |||
{ | |||
String groupId = "a.group.id"; | |||
String artifactId = "artifact-id"; | |||
String version = "1.0-abc-1.1-SNAPSHOT"; | |||
String artifactVersion = "1.0-abc-1.1-20080221.062205-9"; | |||
String classifier = null; | |||
String type = "pom"; | |||
String path = "a/group/id/artifact-id/1.0-abc-1.1-SNAPSHOT/artifact-id-1.0-abc-1.1-20080221.062205-9.pom"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* A timestamped versioned artifact but without release version part. Like on axiom trunk. | |||
*/ | |||
@Test | |||
public void testBadSnapshotWithoutReleasePart() | |||
{ | |||
assertBadPath( "org/apache/ws/commons/axiom/axiom/SNAPSHOT/axiom-20070912.093446-2.pom", | |||
"snapshot version without release part" ); | |||
} | |||
/** | |||
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. | |||
* | |||
* @throws LayoutException | |||
*/ | |||
@Test | |||
public void testClassifiedSnapshotMavenTest() | |||
throws LayoutException | |||
{ | |||
String groupId = "a.group.id"; | |||
String artifactId = "artifact-id"; | |||
String version = "1.0-SNAPSHOT"; | |||
String artifactVersion = "1.0-20070219.171202-34"; | |||
String classifier = "test-sources"; | |||
String type = "jar"; | |||
String path = "a/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-20070219.171202-34-test-sources.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-519] version identifiers within filename cause misidentification of version. | |||
* Example uses "test" in artifact Id, which is also part of the versionKeyword list. | |||
*/ | |||
@Test | |||
public void testGoodVersionKeywordInArtifactId() | |||
throws LayoutException | |||
{ | |||
String groupId = "maven"; | |||
String artifactId = "maven-test-plugin"; | |||
String version = "1.8.2"; | |||
String artifactVersion = "1.8.2"; | |||
String classifier = null; | |||
String type = "pom"; | |||
String path = "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.pom"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
* Example uses "test" in artifact Id, which is also part of the versionKeyword list. | |||
*/ | |||
@Test | |||
public void testGoodDetectMavenTestPlugin() | |||
throws LayoutException | |||
{ | |||
String groupId = "maven"; | |||
String artifactId = "maven-test-plugin"; | |||
String version = "1.8.2"; | |||
String artifactVersion = "1.8.2"; | |||
String classifier = null; | |||
String type = "maven-plugin"; | |||
String path = "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
*/ | |||
@Test | |||
public void testGoodDetectCoberturaMavenPlugin() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.codehaus.mojo"; | |||
String artifactId = "cobertura-maven-plugin"; | |||
String version = "2.1"; | |||
String artifactVersion = "2.1"; | |||
String classifier = null; | |||
String type = "maven-plugin"; | |||
String path = "org/codehaus/mojo/cobertura-maven-plugin/2.1/cobertura-maven-plugin-2.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
@Test | |||
public void testToArtifactOnEmptyPath() | |||
{ | |||
try | |||
{ | |||
parser.toItemSelector( "" ); | |||
fail( "Should have failed due to empty path." ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
@Test | |||
public void testToArtifactOnNullPath() | |||
{ | |||
try | |||
{ | |||
parser.toItemSelector( null ); | |||
fail( "Should have failed due to null path." ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
@Test | |||
public void testToArtifactReferenceOnEmptyPath() | |||
{ | |||
try | |||
{ | |||
parser.toItemSelector( "" ); | |||
fail( "Should have failed due to empty path." ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
@Test | |||
public void testToArtifactReferenceOnNullPath() | |||
{ | |||
try | |||
{ | |||
parser.toItemSelector( null ); | |||
fail( "Should have failed due to null path." ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
/** | |||
* Perform a path to artifact reference lookup, and verify the results. | |||
*/ | |||
private void assertLayout( String path, String groupId, String artifactId, String version, String artifactVersion, String classifier, | |||
String type ) | |||
throws LayoutException | |||
{ | |||
// Path to Artifact Reference. | |||
ItemSelector testReference = parser.toItemSelector( path ); | |||
assertArtifactReference( testReference, groupId, artifactId, version, artifactVersion, classifier, type ); | |||
} | |||
private void assertArtifactReference( ItemSelector actualReference, String groupId, String artifactId, | |||
String version, String artifactVersion, String classifier, String type ) | |||
{ | |||
String expectedId = | |||
"ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; | |||
assertNotNull( expectedId + " - Should not be null.", actualReference ); | |||
assertEquals( expectedId + " - Group ID", groupId, actualReference.getNamespace() ); | |||
assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() ); | |||
assertEquals( expectedId + " - Artifact Version", artifactVersion, actualReference.getArtifactVersion( ) ); | |||
if ( StringUtils.isNotBlank( classifier ) ) | |||
{ | |||
assertEquals( expectedId + " - Classifier", classifier, actualReference.getClassifier() ); | |||
} | |||
assertEquals( expectedId + " - Version ID", version, actualReference.getVersion() ); | |||
assertEquals( expectedId + " - Type", type, actualReference.getType() ); | |||
} | |||
private void assertBadPath( String path, String reason ) | |||
{ | |||
try | |||
{ | |||
parser.toItemSelector( path ); | |||
fail( | |||
"Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
} |
@@ -24,6 +24,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.configuration.FileType; | |||
import org.apache.archiva.configuration.FileTypes; | |||
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; | |||
@@ -96,6 +97,11 @@ public class ManagedDefaultRepositoryContentTest | |||
@Inject | |||
FileLockManager fileLockManager; | |||
@Inject | |||
@Named( "repositoryPathTranslator#maven2" ) | |||
RepositoryPathTranslator pathTranslator; | |||
private Path getRepositoryPath(String repoName) { | |||
try | |||
{ | |||
@@ -121,9 +127,11 @@ public class ManagedDefaultRepositoryContentTest | |||
fileTypes.afterConfigurationChange( null, "fileType", null ); | |||
repoContent = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, fileTypes, fileLockManager); | |||
repoContent = new ManagedDefaultRepositoryContent(repository, fileTypes, fileLockManager); | |||
repoContent.setMavenContentHelper( contentHelper ); | |||
repoContent.setMetadataReader( metadataReader ); | |||
repoContent.setPathTranslator( pathTranslator ); | |||
repoContent.setArtifactMappingProviders( artifactMappingProviders ); | |||
//repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" ); | |||
} | |||
@@ -435,7 +443,7 @@ public class ManagedDefaultRepositoryContentTest | |||
fileTypes.afterConfigurationChange( null, "fileType", null ); | |||
repoContent = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, fileTypes, fileLockManager); | |||
repoContent = new ManagedDefaultRepositoryContent(repository, fileTypes, fileLockManager); | |||
return newRepo; | |||
} | |||
@@ -1173,7 +1181,7 @@ public class ManagedDefaultRepositoryContentTest | |||
{ | |||
Path repoDir = copyRepository( sourceRepoName ); | |||
MavenManagedRepository repo = createRepository( sourceRepoName, sourceRepoName, repoDir ); | |||
ManagedDefaultRepositoryContent deleteRepoContent = new ManagedDefaultRepositoryContent( repo, artifactMappingProviders, fileTypes, fileLockManager ); | |||
ManagedDefaultRepositoryContent deleteRepoContent = new ManagedDefaultRepositoryContent( repo, fileTypes, fileLockManager ); | |||
deleteRepoContent.setMavenContentHelper( contentHelper ); | |||
return repo; | |||
} |
@@ -23,6 +23,7 @@ import org.apache.archiva.common.utils.FileUtils; | |||
import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.configuration.FileType; | |||
import org.apache.archiva.configuration.FileTypes; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.content.ItemSelector; | |||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; | |||
@@ -70,6 +71,10 @@ public class MavenRepositoryRequestInfoTest | |||
@Inject | |||
List<? extends ArtifactMappingProvider> artifactMappingProviders; | |||
@Inject | |||
@Named( "repositoryPathTranslator#maven2" ) | |||
RepositoryPathTranslator pathTranslator; | |||
@Inject | |||
FileLockManager fileLockManager; | |||
@@ -110,10 +115,12 @@ public class MavenRepositoryRequestInfoTest | |||
fileTypes.afterConfigurationChange( null, "fileType", null ); | |||
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, fileTypes, fileLockManager); | |||
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repository, fileTypes, fileLockManager); | |||
//repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" ); | |||
repository.setContent(repoContent); | |||
repoContent.setMavenContentHelper( mavenContentHelper ); | |||
repoContent.setArtifactMappingProviders( artifactMappingProviders ); | |||
repoContent.setPathTranslator( pathTranslator ); | |||
repoRequest = new MavenRepositoryRequestInfo(repository); | |||
} |
@@ -18,6 +18,7 @@ package org.apache.archiva.repository.maven.content; | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.LayoutException; | |||
import org.apache.archiva.repository.BaseRepositoryContentLayout; | |||
@@ -31,6 +32,7 @@ import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvi | |||
import org.junit.Before; | |||
import javax.inject.Inject; | |||
import javax.inject.Named; | |||
import java.util.List; | |||
/** | |||
@@ -43,7 +45,11 @@ public class RemoteDefaultRepositoryContentTest | |||
@Inject | |||
private List<? extends ArtifactMappingProvider> artifactMappingProviders; | |||
private RemoteRepositoryContent repoContent; | |||
@Inject | |||
@Named( "repositoryPathTranslator#maven2" ) | |||
RepositoryPathTranslator pathTranslator; | |||
private RemoteDefaultRepositoryContent repoContent; | |||
@Before | |||
public void setUp() | |||
@@ -52,7 +58,10 @@ public class RemoteDefaultRepositoryContentTest | |||
RemoteRepository repository = | |||
createRemoteRepository( "testRemoteRepo", "Unit Test Remote Repo", "http://repo1.maven.org/maven2/" ); | |||
repoContent = new RemoteDefaultRepositoryContent(artifactMappingProviders); | |||
repoContent = new RemoteDefaultRepositoryContent(); | |||
repoContent.setArtifactMappingProviders( artifactMappingProviders ); | |||
repoContent.setPathTranslator( pathTranslator ); | |||
//repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, "default" ); | |||
repoContent.setRepository( repository ); | |||
} |
@@ -34,6 +34,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.configuration.Configuration; | |||
import org.apache.archiva.configuration.FileTypes; | |||
import org.apache.archiva.configuration.RepositoryGroupConfiguration; | |||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.maven.content.MavenContentHelper; | |||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; | |||
@@ -153,6 +154,10 @@ public class ArchivaDavResourceFactoryTest | |||
@Inject | |||
List<? extends ArtifactMappingProvider> artifactMappingProviders; | |||
@Inject | |||
@Named( "repositoryPathTranslator#maven2" ) | |||
RepositoryPathTranslator pathTranslator; | |||
@Inject | |||
FileLockManager fileLockManager; | |||
@@ -260,12 +265,14 @@ public class ArchivaDavResourceFactoryTest | |||
throws RepositoryAdminException | |||
{ | |||
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId ); | |||
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager); | |||
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, fileTypes, fileLockManager); | |||
if (repo!=null && repo instanceof EditableManagedRepository) | |||
{ | |||
( (EditableManagedRepository) repo ).setContent( repoContent ); | |||
} | |||
repoContent.setMavenContentHelper( mavenContentHelper ); | |||
repoContent.setArtifactMappingProviders( artifactMappingProviders ); | |||
repoContent.setPathTranslator( pathTranslator ); | |||
return repoContent; | |||
} | |||