<mockito:mock id="mockManagedRepositoryAdmin" class="org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin" />
<mockito:mock id="mockRemoteRepositoryAdmin" class="org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin" />
- <context:component-scan base-package="org.apache.archiva.repository.mock,org.apache.archiva.repository.content.maven2,$package"/>
+ <context:component-scan base-package="org.apache.archiva.repository.mock,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<alias name="mockRepositoryProvider" alias="mavenRepositoryProvider" />
<alias alias="repositorySessionFactory#jcr" name="repositorySessionFactory#file" />
import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.ReleaseScheme;
+import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
{
if ( repo == null )
{
- repo = applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
- repo.setRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+ org.apache.archiva.repository.ManagedRepository repoCfg = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
+ repo = provider.createManagedContent( repoCfg );
}
return repo;
+++ /dev/null
-package org.apache.archiva.repository.mock;
-
-/*
- * 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.ArchivaArtifact;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.ProjectReference;
-import org.apache.archiva.model.VersionedReference;
-import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.ManagedRepository;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryException;
-import org.apache.archiva.repository.layout.LayoutException;
-import org.springframework.stereotype.Service;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Set;
-
-/**
- * @author Martin Stockhammer <martin_s@apache.org>
- */
-@Service("managedRepositoryContent#mock")
-public class ManagedRepositoryContentMock implements ManagedRepositoryContent
-{
- private ManagedRepository repository;
-
- @Override
- public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException
- {
-
- }
-
- @Override
- public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException
- {
-
- }
-
- @Override
- public void deleteGroupId( String groupId ) throws ContentNotFoundException
- {
-
- }
-
- @Override
- public void deleteProject( String namespace, String projectId ) throws RepositoryException
- {
-
- }
-
- @Override
- public String getId( )
- {
- return null;
- }
-
- @Override
- public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference ) throws ContentNotFoundException
- {
- return null;
- }
-
- @Override
- public String getRepoRoot()
- {
- return convertUriToPath( repository.getLocation() );
- }
-
- private String convertUriToPath( URI uri ) {
- if (uri.getScheme()==null) {
- return Paths.get(uri.getPath()).toString();
- } else if ("file".equals(uri.getScheme())) {
- return Paths.get(uri).toString();
- } else {
- return uri.toString();
- }
- }
-
- @Override
- public ManagedRepository getRepository( )
- {
- return repository;
- }
-
- @Override
- public Set<String> getVersions( ProjectReference reference ) throws ContentNotFoundException, LayoutException
- {
- return null;
- }
-
- @Override
- public Set<String> getVersions( VersionedReference reference ) throws ContentNotFoundException
- {
- return null;
- }
-
- @Override
- public boolean hasContent( ArtifactReference reference )
- {
- return false;
- }
-
- @Override
- public boolean hasContent( ProjectReference reference )
- {
- return false;
- }
-
- @Override
- public boolean hasContent( VersionedReference reference )
- {
- return false;
- }
-
- @Override
- public void setRepository( ManagedRepository repo )
- {
- this.repository = repo;
- }
-
- @Override
- public ArtifactReference toArtifactReference( String path ) throws LayoutException
- {
- return null;
- }
-
- @Override
- public Path toFile( ArtifactReference reference )
- {
- return null;
- }
-
- @Override
- public Path toFile( ArchivaArtifact reference )
- {
- return null;
- }
-
- @Override
- public String toMetadataPath( ProjectReference reference )
- {
- return null;
- }
-
- @Override
- public String toMetadataPath( VersionedReference reference )
- {
- return null;
- }
-
- @Override
- public String toPath( ArtifactReference reference )
- {
- return null;
- }
-
- @Override
- public String toPath( ArchivaArtifact reference )
- {
- return null;
- }
-}
+++ /dev/null
-package org.apache.archiva.repository.mock;
-
-/*
- * 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.model.RepositoryURL;
-import org.apache.archiva.repository.RemoteRepository;
-import org.apache.archiva.repository.RemoteRepositoryContent;
-import org.apache.archiva.repository.layout.LayoutException;
-import org.springframework.stereotype.Service;
-
-/**
- * @author Martin Stockhammer <martin_s@apache.org>
- */
-@Service("remoteRepositoryContent#mock")
-public class RemoteRepositoryContentMock implements RemoteRepositoryContent
-{
- RemoteRepository repository;
-
- @Override
- public String getId( )
- {
- return null;
- }
-
- @Override
- public RemoteRepository getRepository( )
- {
- return null;
- }
-
- @Override
- public RepositoryURL getURL( )
- {
- return null;
- }
-
- @Override
- public void setRepository( RemoteRepository repo )
- {
- this.repository = repo;
- }
-
- @Override
- public ArtifactReference toArtifactReference( String path ) throws LayoutException
- {
- return null;
- }
-
- @Override
- public String toPath( ArtifactReference reference )
- {
- return null;
- }
-
- @Override
- public RepositoryURL toURL( ArtifactReference reference )
- {
- return null;
- }
-}
</bean>
<alias name="archivaConfiguration#cleanup-released-snapshots" alias="archivaConfiguration"/>
<alias name="archivaConfiguration#cleanup-released-snapshots" alias="archivaConfiguration#default"/>
- <context:component-scan base-package="org.apache.archiva.repository.mock,org.apache.archiva.repository.content.maven2"/>
+ <context:component-scan base-package="org.apache.archiva.configuration,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
<alias name="repositoryContentFactory#cleanup-released-snapshots" alias="repositoryContentFactory#default" />
</property>
</bean>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
<alias name="userConfiguration#redback" alias="userConfiguration#default"/>
<!-- ***
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.converter.artifact.ArtifactConversionException;
import org.apache.archiva.converter.artifact.ArtifactConverter;
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
@Named("artifactConverter#legacy-to-default")
private ArtifactConverter artifactConverter;
+ @Inject
+ private List<? extends ArtifactMappingProvider> artifactMappingProviders;
+
+ @Inject
+ private FileTypes fileTypes;
+
private ArtifactFactory artifactFactory;
private ManagedRepositoryContent managedRepository;
public void beginScan( org.apache.archiva.repository.ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.managedRepository = new ManagedDefaultRepositoryContent();
+ this.managedRepository = new ManagedDefaultRepositoryContent(artifactMappingProviders, fileTypes);
this.managedRepository.setRepository( repository );
}
default-lazy-init="false">
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
repo.setLocation( new URI(path) );
repo.setLayout( layout );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
- repoContent.setRepository( repo );
+ provider.createManagedContent( repo );
return repoContent;
}
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
+import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.commons.io.FileUtils;
repo.setLocation( new URI(repoPath) );
repo.setLayout( "default" );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
+ provider.createManagedContent( repo );
- repoContent.setRepository( repo );
managedDefaultRepository = repoContent;
( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
default-lazy-init="true">
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.content.maven2,org.apache.archiva.proxy,org.apache.archiva.repository.mock"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+ <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.proxy,org.apache.archiva.repository.mock"/>
<alias name="mockRepositoryProvider" alias="mavenRepositoryProvider" />
<alias name="archivaConfiguration#mock" alias="archivaConfiguration#default"/>
<context:annotation-config/>
<context:component-scan base-package="org.apache.archiva.admin.mock,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<props>
* ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
* without the need for processing based on filesystem paths, or working with the database.
*/
-public interface ManagedRepositoryContent
+public interface ManagedRepositoryContent extends RepositoryContent
{
+
+
+
/**
* Delete from the managed repository all files / directories associated with the
* provided version reference.
*
* @return the repository that is associated with this repository content.
*/
- org.apache.archiva.repository.ManagedRepository getRepository();
+ ManagedRepository getRepository();
/**
* Given a specific {@link ProjectReference}, return the list of available versions for
*/
void setRepository( org.apache.archiva.repository.ManagedRepository repo );
- /**
- * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
- *
- * @param path the path relative to the repository base dir for the artifact.
- * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to
- * a {@link ArtifactReference})
- * @throws LayoutException if there was a problem converting the path to an artifact.
- */
- ArtifactReference toArtifactReference( String path )
- throws LayoutException;
-
/**
* Given an {@link ArtifactReference}, return the file reference to the artifact.
*
*/
String toMetadataPath( VersionedReference reference );
- /**
- * Given an {@link ArtifactReference}, return the relative path to the artifact.
- *
- * @param reference the artifact reference to use.
- * @return the relative path to the artifact.
- */
- String toPath( ArtifactReference reference );
-
/**
* Given an {@link ArchivaArtifact}, return the relative path to the artifact.
*
*
*
*/
-public interface RemoteRepositoryContent
+public interface RemoteRepositoryContent extends RepositoryContent
{
/**
* <p>
*/
void setRepository( RemoteRepository repo );
- /**
- * Given a repository relative path to a filename, return the {@link org.apache.archiva.model.VersionedReference} object suitable for the path.
- *
- * @param path the path relative to the repository base dir for the artifact.
- * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to
- * a {@link ArtifactReference})
- * @throws LayoutException if there was a problem converting the path to an artifact.
- */
- ArtifactReference toArtifactReference( String path )
- throws LayoutException;
-
- /**
- * Given an ArtifactReference, return the relative path to the artifact.
- *
- * @param reference the artifact reference to use.
- * @return the relative path to the artifact.
- */
- String toPath( ArtifactReference reference );
-
/**
* Given an ArtifactReference, return the url to the artifact.
*
--- /dev/null
+package org.apache.archiva.repository;
+
+/*
+ * 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.model.VersionedReference;
+import org.apache.archiva.repository.layout.LayoutException;
+
+
+/**
+ * Common aspects of content provider interfaces
+ */
+public interface RepositoryContent
+{
+
+
+ /**
+ * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
+ *
+ * @param path the path relative to the repository base dir for the artifact.
+ * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to
+ * a {@link ArtifactReference})
+ * @throws LayoutException if there was a problem converting the path to an artifact.
+ */
+ ArtifactReference toArtifactReference( String path )
+ throws LayoutException;
+
+ /**
+ * Given an {@link ArtifactReference}, return the relative path to the artifact.
+ *
+ * @param reference the artifact reference to use.
+ * @return the relative path to the artifact.
+ */
+ String toPath( ArtifactReference reference );
+}
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Inject
private ApplicationContext applicationContext;
+ @Inject
+ private List<RepositoryContentProvider> repositoryContentProviders;
+
private final Map<String, ManagedRepositoryContent> managedContentMap;
private final Map<String, RemoteRepositoryContent> remoteContentMap;
* @throws RepositoryException the repository content object cannot be loaded due to configuration issue.
*/
public ManagedRepositoryContent getManagedRepositoryContent( String repoId )
- throws RepositoryNotFoundException, RepositoryException
+ throws RepositoryException
{
ManagedRepositoryContent repo = managedContentMap.get( repoId );
}
- public ManagedRepositoryContent getManagedRepositoryContent( ManagedRepositoryConfiguration repoConfig, org.apache.archiva.repository.ManagedRepository mRepo )
- throws RepositoryNotFoundException, RepositoryException
+ private RepositoryContentProvider getProvider(final String layout, final RepositoryType repoType) throws RepositoryException
+ {
+ return repositoryContentProviders.stream().filter(p->p.supports( repoType ) && p.supportsLayout( layout )).
+ findFirst().orElseThrow( ( ) -> new RepositoryException( "Could not find content provider for repository type "+repoType+" and layout "+layout ) );
+ }
+
+ public ManagedRepositoryContent getManagedRepositoryContent( org.apache.archiva.repository.ManagedRepository mRepo )
+ throws RepositoryException
{
- ManagedRepositoryContent repo = managedContentMap.get( repoConfig.getId( ) );
+ final String id = mRepo.getId();
+ ManagedRepositoryContent content = managedContentMap.get( id );
- if ( repo != null && repo.getRepository()==mRepo)
+ if ( content != null && content.getRepository()==mRepo)
{
- return repo;
+ return content;
}
- repo = applicationContext.getBean( "managedRepositoryContent#" + repoConfig.getLayout( ),
- ManagedRepositoryContent.class );
- repo.setRepository( mRepo );
- ManagedRepositoryContent previousRepo = managedContentMap.put( repoConfig.getId( ), repo );
- if (previousRepo!=null) {
- ManagedRepository previousMRepo = previousRepo.getRepository( );
- if (previousMRepo!=null && previousMRepo instanceof EditableManagedRepository) {
- ((EditableManagedRepository)previousMRepo).setContent( null );
- }
- previousRepo.setRepository( null );
+ RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) );
+ content = contentProvider.createManagedContent( mRepo );
+ if (content==null) {
+ throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() );
+ }
+ ManagedRepositoryContent previousContent = managedContentMap.put( id, content );
+ if (previousContent!=null) {
+ previousContent.setRepository( null );
}
- return repo;
+ return content;
}
public RemoteRepositoryContent getRemoteRepositoryContent( String repoId )
- throws RepositoryNotFoundException, RepositoryException
+ throws RepositoryException
{
RemoteRepositoryContent repo = remoteContentMap.get( repoId );
}
- public RemoteRepositoryContent getRemoteRepositoryContent( RemoteRepositoryConfiguration repoConfig, RemoteRepository mRepo )
- throws RepositoryNotFoundException, RepositoryException
+ public RemoteRepositoryContent getRemoteRepositoryContent( RemoteRepository mRepo )
+ throws RepositoryException
{
- RemoteRepositoryContent repo = remoteContentMap.get( repoConfig.getId( ) );
+ final String id = mRepo.getId();
+ RemoteRepositoryContent content = remoteContentMap.get( id );
- if ( repo != null && repo.getRepository()==mRepo)
+ if ( content != null && content.getRepository()==mRepo)
{
- return repo;
+ return content;
}
- repo = applicationContext.getBean( "remoteRepositoryContent#" + repoConfig.getLayout( ),
- RemoteRepositoryContent.class );
- repo.setRepository( mRepo );
- RemoteRepositoryContent previousRepo = remoteContentMap.put( repoConfig.getId( ), repo );
- if (previousRepo!=null) {
- RemoteRepository previousMRepo = previousRepo.getRepository( );
- if (previousMRepo!=null && previousMRepo instanceof EditableRemoteRepository) {
- ((EditableRemoteRepository)previousMRepo).setContent( null );
- }
- previousRepo.setRepository( null );
+ RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) );
+ content = contentProvider.createRemoteContent( mRepo );
+ if (content==null) {
+ throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() );
}
-
-
- return repo;
+ RemoteRepositoryContent previousContent = remoteContentMap.put( id, content );
+ if (previousContent!=null) {
+ previousContent.setRepository( null );
+ }
+ return content;
}
{
this.archivaConfiguration = archivaConfiguration;
}
+
+ public void setRepositoryContentProviders(List<RepositoryContentProvider> providers) {
+ this.repositoryContentProviders = providers;
+ }
+
+ public List<RepositoryContentProvider> getRepositoryContentProviders() {
+ return repositoryContentProviders;
+ }
}
--- /dev/null
+package org.apache.archiva.repository;
+
+/*
+ * 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 java.util.Set;
+
+/**
+ * A repository content provider creates repository content instances for specific repository types.
+ */
+public interface RepositoryContentProvider
+{
+ /**
+ * Returns true, if this content object supports the given layout otherwise, false.
+ * @param layout the layout string
+ * @return true, if layout is supported, otherwise false.
+ */
+ boolean supportsLayout(String layout);
+
+ /**
+ * Returns the repository types, this content object can be used for.
+ *
+ * @return all supported repository types.
+ */
+ Set<RepositoryType> getSupportedRepositoryTypes();
+
+
+ /**
+ * Returns true, if this content object supports the given repository type.
+ *
+ * @param type the type to check.
+ * @return true, if the type is supported, otherwise false.
+ */
+ boolean supports(RepositoryType type);
+
+ /**
+ * Creates a new instance of RemoteRepositoryContent. The returned instance should be initialized
+ * from the given repository data.
+ *
+ * @param repository the repository
+ * @return a repository content instance
+ * @throws RepositoryException if the layout is not supported, or a error occured during initialization
+ */
+ RemoteRepositoryContent createRemoteContent(RemoteRepository repository) throws RepositoryException;
+
+ /**
+ * Creates a new instance of ManagedRepositoryContent.
+ *
+ * @param repository the repository
+ * @return a new instance
+ * @throws RepositoryException if the layout is not supported, or a error occured during initialization
+ */
+ ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException;
+
+ /**
+ * Creates a generic content object.
+ *
+ * @param repository the repository
+ * @param clazz the content class
+ * @param <T> the generic type of the content
+ * @param <V> the generic type of the repository (must correspond to the content class)
+ * @return a new instance
+ * @throws RepositoryException if the clazz, or layout is not supported, or something went wrong during initialization
+ */
+ <T extends RepositoryContent, V extends Repository> T createContent(Class<T> clazz, V repository) throws RepositoryException;
+}
}
if ( repo instanceof EditableManagedRepository && repo.getContent() == null)
{
- ( (EditableManagedRepository) repo ).setContent( repositoryContentFactory.getManagedRepositoryContent( cfg, repo ) );
+ ( (EditableManagedRepository) repo ).setContent( repositoryContentFactory.getManagedRepositoryContent( repo ) );
}
}
{
if ( repo instanceof EditableRemoteRepository && repo.getContent() == null)
{
- ( (EditableRemoteRepository) repo ).setContent( repositoryContentFactory.getRemoteRepositoryContent( cfg, repo ) );
+ ( (EditableRemoteRepository) repo ).setContent( repositoryContentFactory.getRemoteRepositoryContent( repo ) );
}
}
<context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<props>
default-lazy-init="false">
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.content.maven2"/>
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="managedRepoAdmin#test" class="org.apache.archiva.mock.MockManagedRepositoryAdmin">
<property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/>
<context:component-scan
base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<props>
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-lazy-init="true">
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="securitySystem#testable" class="org.apache.archiva.redback.system.DefaultSecuritySystem">
<property name="userManager" ref="userManager#memory"/>
<property name="keyManager" ref="keyManager#memory"/>
<context:property-placeholder system-properties-mode="OVERRIDE"/>
- <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
<bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry">
<property name="properties">
<value>
default-lazy-init="true">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
- <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.webtest.memory,org.apache.archiva.repository.content.maven2"/>
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
+ <context:component-scan base-package="org.apache.archiva.webtest.memory"/>
<alias name="repositorySessionFactory#test" alias="repositorySessionFactory"/>
<context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+ base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils"/>
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
</bean>
-->
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
-
<alias name="repositorySessionFactory#jcr" alias="repositorySessionFactory"/>
<bean name="TestRepositorySessionFactoryBean" class="org.apache.archiva.TestRepositorySessionFactoryBean">
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
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.maven2.ArtifactMappingProvider;
import org.apache.archiva.proxy.DefaultRepositoryProxyConnectors;
import org.apache.archiva.proxy.model.ProxyFetchResult;
import org.apache.archiva.repository.EditableManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RemoteRepository;
+import org.apache.archiva.repository.RemoteRepositoryContent;
+import org.apache.archiva.repository.Repository;
+import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryContentProvider;
+import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
+import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
import org.apache.archiva.repository.content.maven2.RepositoryRequest;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
import static org.easymock.EasyMock.*;
@Inject
DefaultRepositoryGroupAdmin defaultRepositoryGroupAdmin;
+ @Inject
+ List<? extends ArtifactMappingProvider> artifactMappingProviders;
+
+ @Inject
+ FileTypes fileTypes;
+
@Before
@Override
private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
throws RepositoryAdminException
{
- ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
+ ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(artifactMappingProviders, fileTypes);
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
repoContent.setRepository( repo );
if (repo!=null && repo instanceof EditableManagedRepository)
return repoContent;
}
+ private RepositoryContentProvider createRepositoryContentProvider(ManagedRepositoryContent content) {
+ Set<RepositoryType> TYPES = new HashSet<>( );
+ TYPES.add(RepositoryType.MAVEN);
+ return new RepositoryContentProvider( )
+ {
+
+
+ @Override
+ public boolean supportsLayout( String layout )
+ {
+ return true;
+ }
+
+ @Override
+ public Set<RepositoryType> getSupportedRepositoryTypes( )
+ {
+ return TYPES;
+ }
+
+ @Override
+ public boolean supports( RepositoryType type )
+ {
+ return true;
+ }
+
+ @Override
+ public RemoteRepositoryContent createRemoteContent( RemoteRepository repository ) throws RepositoryException
+ {
+ return null;
+ }
+
+ @Override
+ public ManagedRepositoryContent createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
+ {
+ content.setRepository( repository );
+ return content;
+ }
+
+ @Override
+ public <T extends RepositoryContent, V extends Repository> T createContent( Class<T> clazz, V repository ) throws RepositoryException
+ {
+ return null;
+ }
+ };
+ }
+
@After
@Override
public void tearDown()
{
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
- beanFactory.registerSingleton("managedRepositoryContent#legacy", legacyRepo);
+ RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo );
+ beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);
+ RepositoryContentFactory repoContentFactory = applicationContext.getBean( "repositoryContentFactory#default", RepositoryContentFactory.class );
+ repoContentFactory.getRepositoryContentProviders().add(provider);
defaultManagedRepositoryAdmin.addManagedRepository(
createManagedRepository( LEGACY_REPO, Paths.get( "target/test-classes/" + LEGACY_REPO ).toString(),
"legacy" ), false, null );
<context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.webdav.util,org.apache.archiva.common.plexusbridge,org.apache.archiva.repository.content.maven2,org.apache.archiva.repository"/>
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+ base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.webdav.util,org.apache.archiva.common.plexusbridge"/>
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.repository,org.apache.archiva.repository.content.maven2"/>
-
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+ <context:component-scan base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository" />
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
*/
import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
+import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.content.PathParser;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.commons.lang.StringUtils;
/**
* AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
*/
-public abstract class AbstractDefaultRepositoryContent
+public abstract class AbstractDefaultRepositoryContent implements RepositoryContent
{
+
+
protected Logger log = LoggerFactory.getLogger( getClass() );
public static final String MAVEN_METADATA = "maven-metadata.xml";
private PathParser defaultPathParser = new DefaultPathParser();
+
+
/**
*
*/
- @Inject
protected List<? extends ArtifactMappingProvider> artifactMappingProviders;
- @PostConstruct
- protected void initialize()
- {
- // no op
+ AbstractDefaultRepositoryContent(List<? extends ArtifactMappingProvider> artifactMappingProviders) {
+ this.artifactMappingProviders = artifactMappingProviders;
+ }
+
+ public void setArtifactMappingProviders(List<? extends ArtifactMappingProvider> artifactMappingProviders) {
+ this.artifactMappingProviders = artifactMappingProviders;
}
public ArtifactReference toArtifactReference( String path )
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.FileTypes;
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider;
import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
-import javax.inject.Inject;
-import javax.inject.Named;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* ManagedDefaultRepositoryContent
*/
-@Service ("managedRepositoryContent#maven")
-@Scope ("prototype")
public class ManagedDefaultRepositoryContent
extends AbstractDefaultRepositoryContent
implements ManagedRepositoryContent
{
- @Inject
- @Named ( "fileTypes" )
+
private FileTypes filetypes;
+ public void setFileTypes(FileTypes fileTypes) {
+ this.filetypes = fileTypes;
+ }
+
+
+
private org.apache.archiva.repository.ManagedRepository repository;
- public ManagedDefaultRepositoryContent()
+ public ManagedDefaultRepositoryContent(FileTypes fileTypes) {
+ super(Collections.singletonList( new DefaultArtifactMappingProvider() ));
+ setFileTypes( fileTypes );
+ }
+ public ManagedDefaultRepositoryContent( List<? extends ArtifactMappingProvider> artifactMappingProviders, FileTypes fileTypes )
{
- // default to use if there are none supplied as components
- this.artifactMappingProviders = Collections.singletonList( new DefaultArtifactMappingProvider() );
+ super(artifactMappingProviders==null ? Collections.singletonList( new DefaultArtifactMappingProvider() ) : artifactMappingProviders);
+ setFileTypes( fileTypes );
}
@Override
--- /dev/null
+package org.apache.archiva.repository.content.maven2;
+
+/*
+ * 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.configuration.FileTypes;
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RemoteRepository;
+import org.apache.archiva.repository.RemoteRepositoryContent;
+import org.apache.archiva.repository.Repository;
+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.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Maven implementation of the repository content provider. Only default layout and
+ * maven repository types are supported.
+ */
+@Service("repositoryContentProvider#maven")
+public class MavenContentProvider implements RepositoryContentProvider
+{
+
+ @Inject
+ @Named( "fileTypes" )
+ private FileTypes filetypes;
+
+ @Inject
+ protected List<? extends ArtifactMappingProvider> artifactMappingProviders;
+
+
+ private static final Set<RepositoryType> REPOSITORY_TYPES = new HashSet<>( );
+ static {
+ REPOSITORY_TYPES.add(RepositoryType.MAVEN);
+ }
+
+ @Override
+ public boolean supportsLayout( String layout )
+ {
+ return "default".equals( layout );
+ }
+
+ @Override
+ public Set<RepositoryType> getSupportedRepositoryTypes( )
+ {
+ return REPOSITORY_TYPES;
+ }
+
+ @Override
+ public boolean supports( RepositoryType type )
+ {
+ return type.equals( RepositoryType.MAVEN );
+ }
+
+ @Override
+ public RemoteRepositoryContent createRemoteContent( RemoteRepository repository ) throws RepositoryException
+ {
+ if (!supports( repository.getType() )) {
+ throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
+ }
+ if (!supportsLayout( repository.getLayout() )) {
+ throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." );
+ }
+ RemoteDefaultRepositoryContent content = new RemoteDefaultRepositoryContent(artifactMappingProviders);
+ content.setRepository( repository );
+ return content;
+ }
+
+ @Override
+ public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException
+ {
+ if (!supports( repository.getType() )) {
+ throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
+ }
+ if (!supportsLayout( repository.getLayout() )) {
+ throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." );
+ }
+ ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(artifactMappingProviders, filetypes);
+ content.setRepository( repository );
+ return content;
+ }
+
+ @Override
+ public <T extends RepositoryContent, V extends Repository> T createContent( Class<T> clazz, V repository ) throws RepositoryException
+ {
+ if (!supports( repository.getType() )) {
+ throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
+ }
+ if (repository instanceof ManagedRepository && ManagedRepositoryContent.class.isAssignableFrom( clazz ) ) {
+ return (T) this.createManagedContent( (ManagedRepository) repository );
+ } else if (repository instanceof RemoteRepository && RemoteRepository.class.isAssignableFrom( clazz )) {
+ return (T) this.createRemoteContent( (RemoteRepository) repository );
+ } else {
+ throw new RepositoryException( "Repository flavour is not supported: "+repository.getClass().getName() );
+ }
+ }
+
+}
* under the License.
*/
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.RepositoryURL;
import org.apache.archiva.repository.RemoteRepository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
* RemoteDefaultRepositoryContent
*/
-@Service( "remoteRepositoryContent#maven" )
-@Scope( "prototype" )
public class RemoteDefaultRepositoryContent
extends AbstractDefaultRepositoryContent
implements RemoteRepositoryContent
{
private RemoteRepository repository;
+
+ public RemoteDefaultRepositoryContent( List<? extends ArtifactMappingProvider> artifactMappingProviders ) {
+ super(artifactMappingProviders);
+ }
+
@Override
public String getId( )
{
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.EditableManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.junit.Before;
public class ManagedDefaultRepositoryContentTest
extends AbstractDefaultRepositoryContentTestCase
{
- @Inject
- @Named ( "managedRepositoryContent#default" )
- private ManagedRepositoryContent repoContent;
+ private ManagedDefaultRepositoryContent repoContent;
@Inject
FileTypes fileTypes;
@Named ( "archivaConfiguration#default" )
ArchivaConfiguration archivaConfiguration;
+ @Inject
+ List<? extends ArtifactMappingProvider> artifactMappingProviders;
+
@Before
public void setUp()
throws Exception
fileTypes.afterConfigurationChange( null, "fileType", null );
+ repoContent = new ManagedDefaultRepositoryContent(artifactMappingProviders, fileTypes);
//repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" );
repoContent.setRepository( repository );
}
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
+import org.apache.archiva.repository.content.maven2.RemoteDefaultRepositoryContent;
import org.apache.archiva.repository.layout.LayoutException;
import org.junit.Before;
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
/**
* RemoteDefaultRepositoryContentTest
public class RemoteDefaultRepositoryContentTest
extends AbstractDefaultRepositoryContentTestCase
{
+
@Inject
- @Named ( "remoteRepositoryContent#default" )
+ private List<? extends ArtifactMappingProvider> artifactMappingProviders;
+
private RemoteRepositoryContent repoContent;
@Before
RemoteRepository repository =
createRemoteRepository( "testRemoteRepo", "Unit Test Remote Repo", "http://repo1.maven.org/maven2/" );
+ repoContent = new RemoteDefaultRepositoryContent(artifactMappingProviders);
//repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, "default" );
repoContent.setRepository( repository );
}
repo.setLocation( location.toAbsolutePath().toUri() );
repo.setLayout( layout );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
- repoContent.setRepository( repo );
+ provider.createManagedContent( repo );
return repoContent;
}
repo.setLocation( new URI( url ) );
repo.setLayout( layout );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
RemoteRepositoryContent repoContent =
- applicationContext.getBean( "remoteRepositoryContent#" + layout, RemoteRepositoryContent.class );
- repoContent.setRepository( repo );
+ provider.createRemoteContent( repo );
return repoContent;
}
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
repo.setLocation( location.toAbsolutePath().toUri() );
repo.setLayout( layout );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
+
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
- repoContent.setRepository( repo );
+ provider.createManagedContent( repo );
return repoContent;
}
import org.apache.archiva.repository.AbstractRepositoryLayerTestCase;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentProvider;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.commons.io.FileUtils;
MavenManagedRepository repo =
createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
+
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
+
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
- repoContent.setRepository( repo );
+ provider.createManagedContent( repo );
Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );
MavenManagedRepository repoConfig =
createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
+ RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
+
ManagedRepositoryContent repoContent =
- applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
- repoContent.setRepository( repoConfig );
+ provider.createManagedContent( repoConfig );
return repoContent;
}
<context:annotation-config/>
<context:component-scan base-package="org.apache.archiva.metadata.repository.storage.maven2.conf,org.apache.archiva.repository.content.maven2"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
</beans>
\ No newline at end of file
<alias name="archivaConfiguration#repo-request-test" alias="archivaConfiguration#default"/>
<alias name="archivaConfiguration#repo-request-test" alias="archivaConfiguration"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
- <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
-
-
<bean name="registry#configured" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry">
<property name="properties">
<value>
<alias name="archivaConfiguration#test" alias="archivaConfiguration#default"/>
<alias name="archivaConfiguration#test" alias="archivaConfiguration"/>
- <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
<alias name="metadataResolver#test" alias="metadataResolver#default"/>
</beans>
\ No newline at end of file