git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1403507 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.4-M4
@@ -1,4 +1,4 @@ | |||
package org.apache.archiva.proxy; | |||
package org.apache.archiva.proxy.model; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one |
@@ -59,6 +59,14 @@ | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-scheduler-repository-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>maven2-repository</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy-common</artifactId> |
@@ -45,6 +45,8 @@ import org.apache.archiva.policies.urlcache.UrlFailureCache; | |||
import org.apache.archiva.proxy.common.WagonFactory; | |||
import org.apache.archiva.proxy.common.WagonFactoryException; | |||
import org.apache.archiva.proxy.common.WagonFactoryRequest; | |||
import org.apache.archiva.proxy.model.ProxyConnector; | |||
import org.apache.archiva.proxy.model.RepositoryProxyConnectors; | |||
import org.apache.archiva.redback.components.registry.Registry; | |||
import org.apache.archiva.redback.components.registry.RegistryListener; | |||
import org.apache.archiva.redback.components.taskqueue.TaskQueueException; |
@@ -19,6 +19,8 @@ package org.apache.archiva.proxy; | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.proxy.model.ProxyConnector; | |||
import java.util.Comparator; | |||
/** |
@@ -1,91 +0,0 @@ | |||
package org.apache.archiva.proxy; | |||
/* | |||
* 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.policies.ProxyDownloadException; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import java.io.File; | |||
import java.util.List; | |||
/** | |||
* Handler for potential repository proxy connectors. | |||
* | |||
* | |||
*/ | |||
public interface RepositoryProxyConnectors | |||
{ | |||
/** | |||
* Performs the artifact fetch operation against the target repositories | |||
* of the provided source repository. | |||
* | |||
* If the artifact is found, it is downloaded and placed into the source repository | |||
* filesystem. | |||
* | |||
* @param repository the source repository to use. (must be a managed repository) | |||
* @param artifact the artifact to fetch. | |||
* @return the file that was obtained, or null if no content was obtained | |||
* @throws ProxyDownloadException if there was a problem fetching the content from the target repositories. | |||
*/ | |||
public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact ) | |||
throws ProxyDownloadException; | |||
/** | |||
* Performs the metadata fetch operation against the target repositories | |||
* of the provided source repository. | |||
* | |||
* If the metadata is found, it is downloaded and placed into the source repository | |||
* filesystem. | |||
* | |||
* @param repository the source repository to use. (must be a managed repository) | |||
* @param metadata the metadata to fetch. | |||
* @return the file that was obtained, or null if no content was obtained | |||
*/ | |||
public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath ); | |||
/** | |||
* Performs the fetch operation against the target repositories | |||
* of the provided source repository. | |||
* | |||
* @param repository the source repository to use. (must be a managed repository) | |||
* @param path the path of the resource to fetch | |||
* @return the file that was obtained, or null if no content was obtained | |||
*/ | |||
public File fetchFromProxies( ManagedRepositoryContent managedRepository, String path ); | |||
/** | |||
* Get the List of {@link ProxyConnector} objects of the source repository. | |||
* | |||
* @param repository the source repository to look for. | |||
* @return the List of {@link ProxyConnector} objects. | |||
*/ | |||
public List<ProxyConnector> getProxyConnectors( ManagedRepositoryContent repository ); | |||
/** | |||
* Tests to see if the provided repository is a source repository for | |||
* any {@link ProxyConnector} objects. | |||
* | |||
* @param repository the source repository to look for. | |||
* @return true if there are proxy connectors that use the provided | |||
* repository as a source repository. | |||
*/ | |||
public boolean hasProxies( ManagedRepositoryContent repository ); | |||
} |
@@ -34,6 +34,7 @@ import org.apache.archiva.policies.PropagateErrorsDownloadPolicy; | |||
import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy; | |||
import org.apache.archiva.policies.ReleasesPolicy; | |||
import org.apache.archiva.policies.SnapshotsPolicy; | |||
import org.apache.archiva.proxy.model.RepositoryProxyConnectors; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
import org.apache.commons.io.FileUtils; |
@@ -22,6 +22,7 @@ package org.apache.archiva.proxy; | |||
import org.apache.archiva.admin.model.beans.ManagedRepository; | |||
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.commons.io.FileUtils; | |||
import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.configuration.NetworkProxyConfiguration; |
@@ -41,6 +41,7 @@ | |||
<module>archiva-consumers</module> | |||
<module>archiva-repository-layer</module> | |||
<module>archiva-xml-tools</module> | |||
<module>archiva-proxy-api</module> | |||
<module>archiva-proxy-common</module> | |||
<module>archiva-proxy</module> | |||
<module>archiva-transaction</module> |
@@ -38,7 +38,7 @@ import org.apache.archiva.metadata.repository.RepositorySession; | |||
import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMetadataVersionComparator; | |||
import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet; | |||
import org.apache.archiva.model.ArchivaArtifact; | |||
import org.apache.archiva.proxy.RepositoryProxyConnectors; | |||
import org.apache.archiva.proxy.model.RepositoryProxyConnectors; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.RepositoryContentFactory; | |||
import org.apache.archiva.repository.RepositoryException; |
@@ -39,7 +39,7 @@ import org.apache.archiva.maven2.metadata.MavenMetadataReader; | |||
import org.apache.archiva.model.ArchivaRepositoryMetadata; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.policies.ProxyDownloadException; | |||
import org.apache.archiva.proxy.RepositoryProxyConnectors; | |||
import org.apache.archiva.proxy.model.RepositoryProxyConnectors; | |||
import org.apache.archiva.redback.authentication.AuthenticationException; | |||
import org.apache.archiva.redback.authentication.AuthenticationResult; | |||
import org.apache.archiva.redback.authorization.AuthorizationException; |
@@ -44,14 +44,18 @@ | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-maven2-metadata</artifactId> | |||
</dependency> | |||
<dependency> | |||
<!--dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy</artifactId> | |||
</dependency> | |||
</dependency--> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>problem-reports</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy-common</artifactId> |
@@ -46,8 +46,8 @@ import org.apache.archiva.model.ArchivaRepositoryMetadata; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.model.SnapshotVersion; | |||
import org.apache.archiva.policies.ProxyDownloadException; | |||
import org.apache.archiva.proxy.RepositoryProxyConnectors; | |||
import org.apache.archiva.proxy.common.WagonFactory; | |||
import org.apache.archiva.proxy.model.RepositoryProxyConnectors; | |||
import org.apache.archiva.reports.RepositoryProblemFacet; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.xml.XMLException; |
@@ -30,13 +30,12 @@ import org.springframework.test.context.ContextConfiguration; | |||
import static org.junit.Assert.*; | |||
/** | |||
* AbstractDefaultRepositoryContentTestCase | |||
* | |||
* | |||
* AbstractDefaultRepositoryContentTestCase | |||
*/ | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) | |||
public abstract class AbstractDefaultRepositoryContentTestCase | |||
extends AbstractRepositoryLayerTestCase | |||
{ | |||
@Test | |||
public void testBadPathMissingType() | |||
@@ -47,7 +46,8 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
@Test | |||
public void testBadPathReleaseInSnapshotDir() | |||
{ | |||
assertBadPath( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", "non snapshot artifact inside of a snapshot dir" ); | |||
assertBadPath( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", | |||
"non snapshot artifact inside of a snapshot dir" ); | |||
} | |||
@Test | |||
@@ -82,10 +82,12 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
"wrong artifact id" ); | |||
} | |||
/** | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecGanymedSsh2() | |||
@@ -104,7 +106,9 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxComm() | |||
@@ -144,7 +148,9 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxPersistence() | |||
@@ -241,14 +247,17 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
String version = "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"; | |||
String path = | |||
"com/company/department/com.company.department.project/0.3/com.company.department.project-0.3.pom"; | |||
assertLayout( path, groupId, artifactId, version, classifier, type ); | |||
} | |||
/** | |||
* Test the classifier, and java-source type spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodFooLibSources() | |||
@@ -266,7 +275,9 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
/** | |||
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodSnapshotMavenTest() | |||
@@ -277,7 +288,8 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
String version = "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"; | |||
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, classifier, type ); | |||
} | |||
@@ -299,7 +311,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
assertLayout( path, groupId, artifactId, version, 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. | |||
@@ -410,8 +422,8 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId, | |||
String version, String classifier, String type ) | |||
{ | |||
String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier | |||
+ ":" + type; | |||
String expectedId = | |||
"ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; | |||
assertNotNull( expectedId + " - Should not be null.", actualReference ); | |||
@@ -430,7 +442,8 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
try | |||
{ | |||
toArtifactReference( path ); | |||
fail( "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); | |||
fail( | |||
"Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
@@ -462,7 +475,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase | |||
assertEquals( "Artifact <" + expectedArtifact + "> to path:", path, toPath( testReference ) ); | |||
} | |||
private ArtifactReference createArtifact( String groupId, String artifactId, String version, String classifier, | |||
protected ArtifactReference createArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type ) | |||
{ | |||
ArtifactReference artifact = new ArtifactReference(); |
@@ -49,22 +49,21 @@ import static org.junit.Assert.fail; | |||
/** | |||
* ManagedDefaultRepositoryContentTest | |||
* | |||
* | |||
*/ | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) | |||
public class ManagedDefaultRepositoryContentTest | |||
extends AbstractRepositoryLayerTestCase | |||
extends AbstractDefaultRepositoryContentTestCase | |||
{ | |||
@Inject | |||
@Named( value = "managedRepositoryContent#default" ) | |||
@Named ( value = "managedRepositoryContent#default" ) | |||
private ManagedRepositoryContent repoContent; | |||
@Inject | |||
FileTypes fileTypes; | |||
@Inject @Named(value = "archivaConfiguration#default") | |||
@Inject | |||
@Named ( value = "archivaConfiguration#default" ) | |||
ArchivaConfiguration archivaConfiguration; | |||
@Before | |||
@@ -75,9 +74,7 @@ public class ManagedDefaultRepositoryContentTest | |||
ManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir ); | |||
FileType fileType = | |||
(FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 ); | |||
FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 ); | |||
fileType.addPattern( "**/*.xml" ); | |||
assertEquals( FileTypes.ARTIFACTS, fileType.getId() ); | |||
@@ -50,7 +50,7 @@ import static org.junit.Assert.*; | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) | |||
public class ManagedLegacyRepositoryContentTest | |||
extends AbstractRepositoryLayerTestCase | |||
extends AbstractDefaultRepositoryContentTestCase | |||
{ | |||
@Inject | |||
@Named( value = "managedRepositoryContent#legacy" ) |
@@ -345,6 +345,11 @@ | |||
<artifactId>archiva-policies</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy-api</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy</artifactId> |