You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/08/12 06:31:57 UTC
svn commit: r430971 [1/2] - in /maven/repository-manager/trunk: ./
maven-repository-configuration/
maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/
maven-repository-configuration/src/main/mdo/ maven-repository-con...
Author: brett
Date: Fri Aug 11 21:31:55 2006
New Revision: 430971
URL: http://svn.apache.org/viewvc?rev=430971&view=rev
Log:
[MRM-138] rewritten the proxy and cleaned house. Moved maven-proxy config loader to config module and boosted tests. More tests still needed on proxy, core and webapp.
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoader.java
- copied, changed from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
maven/repository-manager/trunk/maven-repository-configuration/src/test/
maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/
maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml (with props)
maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/maven-proxy-complete.conf
- copied, changed from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf
maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml (with props)
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java (with props)
maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoaderTest.java
- copied, changed from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/
maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml (with props)
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java (with props)
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java (with props)
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java (with props)
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java (with props)
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ProxiedArtifactRepository.java (with props)
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ProxyRequestHandler.java (with props)
maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java
- copied, changed from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/DefaultProxyManagerTest.java
Removed:
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/
maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/
maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/
maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/DefaultProxyManagerTest.java
maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/LegacyProxyManagerTest.java
maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/proxy/web/action/RepositoryProxyAction.java
maven/repository-manager/trunk/maven-repository-webapp/src/test/java/org/apache/maven/repository/proxy/web/action/test/RepositoryProxyActionTest.java
maven/repository-manager/trunk/maven-repository-webapp/src/test/java/org/apache/maven/repository/proxy/web/action/test/stub/ProxyManagerStub.java
Modified:
maven/repository-manager/trunk/maven-repository-configuration/pom.xml
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java
maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
maven/repository-manager/trunk/maven-repository-core/pom.xml
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java
maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java
maven/repository-manager/trunk/maven-repository-indexer/pom.xml
maven/repository-manager/trunk/maven-repository-proxy/pom.xml
maven/repository-manager/trunk/maven-repository-webapp/pom.xml
maven/repository-manager/trunk/pom.xml
Modified: maven/repository-manager/trunk/maven-repository-configuration/pom.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/pom.xml?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/pom.xml Fri Aug 11 21:31:55 2006
@@ -18,6 +18,12 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>1.2_Java1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -44,9 +50,12 @@
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<instrumentation>
- <!-- TODO: should this module have tests? -->
+ <!-- exclude generated -->
<excludes>
- <exclude>**/**</exclude>
+ <exclude>org/apache/maven/repository/configuration/io/**</exclude>
+ <exclude>org/apache/maven/repository/configuration/*RepositoryConfiguration.*</exclude>
+ <exclude>org/apache/maven/repository/configuration/Configuration.*</exclude>
+ <exclude>org/apache/maven/repository/configuration/Proxy.*</exclude>
</excludes>
</instrumentation>
</configuration>
Modified: maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java Fri Aug 11 21:31:55 2006
@@ -33,6 +33,7 @@
* Get the configuration from the store. A cached version may be used.
*
* @return the configuration
+ * @throws ConfigurationStoreException if there is a problem loading the configuration
*/
Configuration getConfigurationFromStore()
throws ConfigurationStoreException;
Modified: maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java Fri Aug 11 21:31:55 2006
@@ -39,7 +39,7 @@
* @todo would be great for plexus to do this for us - so the configuration would be a component itself rather than this store
* @todo would be good to monitor the store file for changes
* @todo support other implementations than XML file
- * @plexus.component role="org.apache.maven.repository.configuration.ConfigurationStore"
+ * @plexus.component
*/
public class DefaultConfigurationStore
extends AbstractLogEnabled
@@ -121,6 +121,8 @@
FileWriter fileWriter = null;
try
{
+ file.getParentFile().mkdirs();
+
fileWriter = new FileWriter( file );
writer.write( fileWriter, configuration );
}
Modified: maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java Fri Aug 11 21:31:55 2006
@@ -26,6 +26,12 @@
{
private final String name;
+ public InvalidConfigurationException( String name, String message )
+ {
+ super( message );
+ this.name = name;
+ }
+
public InvalidConfigurationException( String name, String message, Throwable cause )
{
super( message, cause );
Copied: maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoader.java (from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java)
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoader.java?p2=maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoader.java&p1=maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java&r1=430652&r2=430971&rev=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoader.java Fri Aug 11 21:31:55 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.repository.proxy.configuration;
+package org.apache.maven.repository.configuration;
/*
* Copyright 2005-2006 The Apache Software Foundation.
@@ -16,20 +16,17 @@
* limitations under the License.
*/
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.repository.proxy.repository.ProxyRepository;
import org.codehaus.plexus.util.StringUtils;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
/**
* @author Ben Walding
+ * @author Brett Porter
*/
public class MavenProxyPropertyLoader
{
@@ -39,16 +36,19 @@
private static final String REPO_LIST = "repo.list";
- public ProxyConfiguration load( Properties props )
- throws ValidationException
+ public void load( Properties props, Configuration configuration )
+ throws InvalidConfigurationException
{
- ProxyConfiguration config = new ProxyConfiguration();
+ // set up the managed repository
+ String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE );
- config.setLayout( "default" );
+ RepositoryConfiguration config = new RepositoryConfiguration();
+ config.setDirectory( localCachePath );
+ config.setName( "Imported Maven-Proxy Cache" );
+ config.setId( "maven-proxy" );
+ configuration.addRepository( config );
- config.setRepositoryCachePath( getMandatoryProperty( props, REPO_LOCAL_STORE ) );
-
- //just get the first proxy and break
+ //just get the first HTTP proxy and break
String propertyList = props.getProperty( PROXY_LIST );
if ( propertyList != null )
{
@@ -58,21 +58,15 @@
String key = tok.nextToken();
if ( StringUtils.isNotEmpty( key ) )
{
- String host = getMandatoryProperty( props, "proxy." + key + ".host" );
- int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) );
+ Proxy proxy = new Proxy();
+ proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) );
+ proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) );
// the username and password isn't required
- String username = props.getProperty( "proxy." + key + ".username" );
- String password = props.getProperty( "proxy." + key + ".password" );
+ proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) );
+ proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) );
- if ( StringUtils.isNotEmpty( username ) )
- {
- config.setHttpProxy( host, port, username, password );
- }
- else
- {
- config.setHttpProxy( host, port );
- }
+ configuration.setProxy( proxy );
//accept only one proxy configuration
break;
@@ -80,8 +74,6 @@
}
}
- List repositories = new ArrayList();
-
//get the remote repository list
String repoList = getMandatoryProperty( props, REPO_LIST );
@@ -97,26 +89,21 @@
boolean cacheFailures =
Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue();
boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue();
- long cachePeriod = Long.parseLong( repoProps.getProperty( "cache.period", "0" ) );
-
- ProxyRepository repository =
- new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures, cachePeriod );
+ int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) );
- repository.setHardfail( hardFail );
+ ProxiedRepositoryConfiguration repository = new ProxiedRepositoryConfiguration();
+ repository.setId( key );
+ repository.setLayout( "legacy" );
+ repository.setManagedRepository( config.getId() );
+ repository.setName( "Imported Maven-Proxy Remote Proxy" );
+ repository.setSnapshotsInterval( cachePeriod );
+ repository.setUrl( url );
+ repository.setUseNetworkProxy( StringUtils.isNotEmpty( proxyKey ) );
+ repository.setCacheFailures( cacheFailures );
+ repository.setHardFail( hardFail );
- if ( StringUtils.isNotEmpty( proxyKey ) )
- {
- repository.setProxied( true );
- }
-
- repositories.add( repository );
+ configuration.addProxiedRepository( repository );
}
-
- config.setRepositories( repositories );
-
- config.validate();
-
- return config;
}
private Properties getSubset( Properties props, String prefix )
@@ -136,22 +123,22 @@
return result;
}
- public ProxyConfiguration load( InputStream is )
- throws IOException, ValidationException
+ public void load( InputStream is, Configuration configuration )
+ throws IOException, InvalidConfigurationException
{
Properties props = new Properties();
props.load( is );
- return load( props );
+ load( props, configuration );
}
private String getMandatoryProperty( Properties props, String key )
- throws ValidationException
+ throws InvalidConfigurationException
{
String value = props.getProperty( key );
if ( value == null )
{
- throw new ValidationException( "Missing property: " + key );
+ throw new InvalidConfigurationException( key, "Missing required field: " + key );
}
return value;
Modified: maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo Fri Aug 11 21:31:55 2006
@@ -329,7 +329,7 @@
<field>
<name>snapshotsInterval</name>
<version>1.0.0</version>
- <type>String</type>
+ <type>int</type>
<description>
The interval in minutes before updating snapshots if the policy is set to 'interval'.
</description>
@@ -347,7 +347,7 @@
<field>
<name>releasesInterval</name>
<version>1.0.0</version>
- <type>String</type>
+ <type>int</type>
<description>
The interval in minutes before updating releases if the policy is set to 'interval'.
</description>
@@ -359,6 +359,24 @@
<defaultValue>false</defaultValue>
<description>
Whether to use the network proxy, if one is configured for the protocol of this repository.
+ </description>
+ </field>
+ <field>
+ <name>cacheFailures</name>
+ <version>1.0.0</version>
+ <type>boolean</type>
+ <defaultValue>false</defaultValue>
+ <description>
+ Whether to cache failures to avoid re-attempting them over the network.
+ </description>
+ </field>
+ <field>
+ <name>hardFail</name>
+ <version>1.0.0</version>
+ <type>boolean</type>
+ <defaultValue>false</defaultValue>
+ <description>
+ Whether to cause the entire request to fail if attempts to retrieve from this proxy fail.
</description>
</field>
</fields>
Added: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml (added)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml Fri Aug 11 21:31:55 2006
@@ -0,0 +1,16 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/corrupt.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/maven-proxy-complete.conf (from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf)
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/maven-proxy-complete.conf?p2=maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/maven-proxy-complete.conf&p1=maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf&r1=430652&r2=430971&rev=430971&view=diff
==============================================================================
(empty)
Added: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml (added)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml Fri Aug 11 21:31:55 2006
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<configuration>
+ <repositories>
+ <repository>
+ <directory>managed-repository</directory>
+ <id>local</id>
+ <name>local</name>
+ </repository>
+ </repositories>
+ <proxiedRepositories>
+ <proxiedRepository>
+ <url>http://www.ibiblio.org/maven2/</url>
+ <managedRepository>local</managedRepository>
+ <snapshotsInterval></snapshotsInterval>
+ <releasesInterval></releasesInterval>
+ <useNetworkProxy>true</useNetworkProxy>
+ <id>ibiblio</id>
+ <name>Ibiblio</name>
+ </proxiedRepository>
+ </proxiedRepositories>
+ <syncedRepositories>
+ <syncedRepository>
+ <id>apache</id>
+ <name>ASF</name>
+ <cronExpression>0 0 * * * ?</cronExpression>
+ <managedRepository>local</managedRepository>
+ <method>rsync</method>
+ <properties>
+ <rsyncHost>host</rsyncHost>
+ <rsyncMethod>ssh</rsyncMethod>
+ </properties>
+ </syncedRepository>
+ </syncedRepositories>
+ <localRepository>local-repository</localRepository>
+ <indexPath>.index</indexPath>
+</configuration>
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/conf/repository-manager.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java (added)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java Fri Aug 11 21:31:55 2006
@@ -0,0 +1,150 @@
+package org.apache.maven.repository.configuration;
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.easymock.MockControl;
+
+import java.io.File;
+import java.util.Properties;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Test the configuration store.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ConfigurationStoreTest
+ extends PlexusTestCase
+{
+ public void testInvalidFile()
+ throws Exception
+ {
+ ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "invalid-file" );
+
+ Configuration configuration = configurationStore.getConfigurationFromStore();
+
+ // check default configuration
+ assertNotNull( "check configuration returned", configuration );
+ assertEquals( "check configuration has default elements", "0 0 * * * ?",
+ configuration.getIndexerCronExpression() );
+ assertNull( "check configuration has default elements", configuration.getIndexPath() );
+ assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() );
+ }
+
+ public void testCorruptFile()
+ throws Exception
+ {
+ ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "corrupt-file" );
+
+ try
+ {
+ configurationStore.getConfigurationFromStore();
+ fail( "Configuration should not have succeeded" );
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ // expected
+ assertTrue( true );
+ }
+ }
+
+ public void testGetConfiguration()
+ throws Exception
+ {
+ ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "default" );
+
+ Configuration configuration = configurationStore.getConfigurationFromStore();
+
+ assertEquals( "check indexPath", ".index", configuration.getIndexPath() );
+ assertEquals( "check localRepository", "local-repository", configuration.getLocalRepository() );
+
+ assertEquals( "check managed repositories", 1, configuration.getRepositories().size() );
+ RepositoryConfiguration repository =
+ (RepositoryConfiguration) configuration.getRepositories().iterator().next();
+
+ assertEquals( "check managed repositories", "managed-repository", repository.getDirectory() );
+ assertEquals( "check managed repositories", "local", repository.getName() );
+ assertEquals( "check managed repositories", "local", repository.getId() );
+ assertEquals( "check managed repositories", "default", repository.getLayout() );
+ assertTrue( "check managed repositories", repository.isIndexed() );
+
+ assertEquals( "check proxied repositories", 1, configuration.getProxiedRepositories().size() );
+ ProxiedRepositoryConfiguration proxiedRepository =
+ (ProxiedRepositoryConfiguration) configuration.getProxiedRepositories().iterator().next();
+
+ assertEquals( "check proxied repositories", "local", proxiedRepository.getManagedRepository() );
+ assertEquals( "check proxied repositories", "http://www.ibiblio.org/maven2/", proxiedRepository.getUrl() );
+ assertEquals( "check proxied repositories", "ibiblio", proxiedRepository.getId() );
+ assertEquals( "check proxied repositories", "Ibiblio", proxiedRepository.getName() );
+ assertEquals( "check proxied repositories", 0, proxiedRepository.getSnapshotsInterval() );
+ assertEquals( "check proxied repositories", 0, proxiedRepository.getReleasesInterval() );
+ assertTrue( "check proxied repositories", proxiedRepository.isUseNetworkProxy() );
+
+ assertEquals( "check synced repositories", 1, configuration.getSyncedRepositories().size() );
+ SyncedRepositoryConfiguration syncedRepository =
+ (SyncedRepositoryConfiguration) configuration.getSyncedRepositories().iterator().next();
+
+ assertEquals( "check synced repositories", "local", syncedRepository.getManagedRepository() );
+ assertEquals( "check synced repositories", "apache", syncedRepository.getId() );
+ assertEquals( "check synced repositories", "ASF", syncedRepository.getName() );
+ assertEquals( "check synced repositories", "0 0 * * * ?", syncedRepository.getCronExpression() );
+ assertEquals( "check synced repositories", "rsync", syncedRepository.getMethod() );
+ Properties properties = new Properties();
+ properties.setProperty( "rsyncHost", "host" );
+ properties.setProperty( "rsyncMethod", "ssh" );
+ assertEquals( "check synced repositories", properties, syncedRepository.getProperties() );
+ }
+
+ public void testStoreConfiguration()
+ throws Exception
+ {
+ ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "save-file" );
+
+ Configuration configuration = new Configuration();
+ configuration.setIndexPath( "index-path" );
+
+ File file = getTestFile( "target/test/test-file.xml" );
+ file.delete();
+ assertFalse( file.exists() );
+
+ configurationStore.storeConfiguration( configuration );
+
+ assertTrue( "Check file exists", file.exists() );
+
+ // read it back
+ configuration = configurationStore.getConfigurationFromStore();
+ assertEquals( "check value", "index-path", configuration.getIndexPath() );
+ }
+
+ public void testChangeListeners()
+ throws Exception
+ {
+ ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "save-file" );
+
+ MockControl control = MockControl.createControl( ConfigurationChangeListener.class );
+ ConfigurationChangeListener mock = (ConfigurationChangeListener) control.getMock();
+ configurationStore.addChangeListener( mock );
+
+ Configuration configuration = new Configuration();
+ mock.notifyOfConfigurationChange( configuration );
+ control.replay();
+
+ configurationStore.storeConfiguration( configuration );
+
+ control.verify();
+ }
+}
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/ConfigurationStoreTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoaderTest.java (from r430652, maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java)
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoaderTest.java?p2=maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoaderTest.java&p1=maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java&r1=430652&r2=430971&rev=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/test/java/org/apache/maven/repository/configuration/MavenProxyPropertyLoaderTest.java Fri Aug 11 21:31:55 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.repository.proxy.configuration;
+package org.apache.maven.repository.configuration;
/*
* Copyright 2005-2006 The Apache Software Foundation.
@@ -16,14 +16,13 @@
* limitations under the License.
*/
-import org.apache.maven.repository.proxy.repository.ProxyRepository;
import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-
+import java.util.List;
+import java.util.Properties;
/**
* @author Edwin Punzalan
@@ -33,54 +32,72 @@
{
private static final int DEFAULT_CACHE_PERIOD = 3600;
+ private MavenProxyPropertyLoader loader;
+
public void testLoadValidMavenProxyConfiguration()
- throws ValidationException, IOException
+ throws IOException, InvalidConfigurationException
{
- MavenProxyPropertyLoader loader = new MavenProxyPropertyLoader();
+ File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
- //must create the test directory bec configuration is using relative path which varies
- FileUtils.mkdir( "target/remote-repo1" );
+ Configuration configuration = new Configuration();
+ Proxy proxy = new Proxy();
+ proxy.setHost( "original-host" );
+ configuration.setProxy( proxy ); // overwritten
+ configuration.setIndexPath( "index-path" ); // existing value
+
+ loader.load( new FileInputStream( confFile ), configuration );
+
+ List list = configuration.getRepositories();
+ assertEquals( "check single managed repository", 1, list.size() );
+ RepositoryConfiguration managedRepository = (RepositoryConfiguration) list.iterator().next();
+ assertEquals( "cache path changed", "target", managedRepository.getDirectory() );
+
+ assertEquals( "Count repositories", 4, configuration.getProxiedRepositories().size() );
+
+ list = configuration.getProxiedRepositories();
+ ProxiedRepositoryConfiguration repo = (ProxiedRepositoryConfiguration) list.get( 0 );
+ assertEquals( "Repository name not as expected", "local-repo", repo.getId() );
+ assertEquals( "Repository url does not match its name", "file://target", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", 0, repo.getSnapshotsInterval() );
+ assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxiedRepositoryConfiguration) list.get( 1 );
+ assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getId() );
+ assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getSnapshotsInterval() );
+ assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxiedRepositoryConfiguration) list.get( 2 );
+ assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getId() );
+ assertEquals( "Repository url does not match its name", "http://dist.codehaus.org", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getSnapshotsInterval() );
+ assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxiedRepositoryConfiguration) list.get( 3 );
+ assertEquals( "Repository name not as expected", "private-example-com", repo.getId() );
+ assertEquals( "Repository url does not match its name", "http://private.example.com/internal", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getSnapshotsInterval() );
+ assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
+ }
+ public void testInvalidConfiguration()
+ {
+ Configuration configuration = new Configuration();
try
{
- File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
-
- ProxyConfiguration config = loader.load( new FileInputStream( confFile ) );
-
- assertTrue( "cache path changed", config.getRepositoryCachePath().endsWith( "target" ) );
-
- assertEquals( "Count repositories", 4, config.getRepositories().size() );
-
- ProxyRepository repo = (ProxyRepository) config.getRepositories().get( 0 );
- assertEquals( "Repository name not as expected", "local-repo", repo.getKey() );
- assertEquals( "Repository url does not match its name", "file://target", repo.getUrl() );
- assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() );
- assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
-
- repo = (ProxyRepository) config.getRepositories().get( 1 );
- assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2", repo.getUrl() );
- assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
- assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
-
- repo = (ProxyRepository) config.getRepositories().get( 2 );
- assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://dist.codehaus.org", repo.getUrl() );
- assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
- assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
-
- repo = (ProxyRepository) config.getRepositories().get( 3 );
- assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://private.example.com/internal",
- repo.getUrl() );
- assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
- assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
+ loader.load( new Properties(), configuration );
+ fail( "Incomplete config should have failed" );
}
- finally
+ catch ( InvalidConfigurationException e )
{
- //make sure to delete the test directory after tests
- FileUtils.deleteDirectory( "target/remote-repo1" );
+ assertTrue( true );
}
}
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ loader = new MavenProxyPropertyLoader();
+ }
}
Added: maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml (added)
+++ maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml Fri Aug 11 21:31:55 2006
@@ -0,0 +1,52 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.repository.configuration.ConfigurationStore</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.repository.configuration.DefaultConfigurationStore</implementation>
+ <configuration>
+ <file>${basedir}/src/test/conf/repository-manager.xml</file>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.repository.configuration.ConfigurationStore</role>
+ <role-hint>corrupt-file</role-hint>
+ <implementation>org.apache.maven.repository.configuration.DefaultConfigurationStore</implementation>
+ <configuration>
+ <file>${basedir}/src/test/conf/corrupt.xml</file>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.repository.configuration.ConfigurationStore</role>
+ <role-hint>invalid-file</role-hint>
+ <implementation>org.apache.maven.repository.configuration.DefaultConfigurationStore</implementation>
+ <configuration>
+ <file>${basedir}/src/test/conf/nada.txt</file>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.repository.configuration.ConfigurationStore</role>
+ <role-hint>save-file</role-hint>
+ <implementation>org.apache.maven.repository.configuration.DefaultConfigurationStore</implementation>
+ <configuration>
+ <file>${basedir}/target/test/test-file.xml</file>
+ </configuration>
+ </component>
+ </components>
+</component-set>
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-configuration/src/test/resources/org/apache/maven/repository/configuration/ConfigurationStoreTest.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/repository-manager/trunk/maven-repository-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/pom.xml?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-core/pom.xml Fri Aug 11 21:31:55 2006
@@ -24,19 +24,16 @@
</dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-proxy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-reports-standard</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-quartz</artifactId>
<version>1.0-alpha-2</version>
- </dependency>
- <!-- Testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
</dependency>
</dependencies>
</project>
Modified: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java (original)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java Fri Aug 11 21:31:55 2006
@@ -52,4 +52,20 @@
* @return the local artifact repository
*/
ArtifactRepository createLocalRepository( Configuration configuration );
+
+ /**
+ * Create an artifact repository from the given proxy repository configuration.
+ *
+ * @param configuration the configuration
+ * @return the artifact repository
+ */
+ ArtifactRepository createProxiedRepository( ProxiedRepositoryConfiguration configuration );
+
+ /**
+ * Create artifact repositories from the given proxy repository configurations.
+ *
+ * @param configuration the configuration containing the repositories
+ * @return the artifact repositories
+ */
+ List createProxiedRepositories( Configuration configuration );
}
Modified: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java (original)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java Fri Aug 11 21:31:55 2006
@@ -18,6 +18,7 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import java.io.File;
@@ -54,11 +55,30 @@
return repoFactory.createArtifactRepository( configuration.getId(), repoDir, layout, null, null );
}
+ public ArtifactRepository createProxiedRepository( ProxiedRepositoryConfiguration configuration )
+ {
+ boolean enabled = isEnabled( configuration.getSnapshotsPolicy() );
+ String updatePolicy =
+ getUpdatePolicy( configuration.getSnapshotsPolicy(), configuration.getSnapshotsInterval() );
+ ArtifactRepositoryPolicy snapshotsPolicy =
+ new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
+
+ enabled = isEnabled( configuration.getReleasesPolicy() );
+ updatePolicy = getUpdatePolicy( configuration.getReleasesPolicy(), configuration.getReleasesInterval() );
+ ArtifactRepositoryPolicy releasesPolicy =
+ new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
+
+ ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() );
+ return repoFactory.createArtifactRepository( configuration.getId(), configuration.getUrl(), layout,
+ snapshotsPolicy, releasesPolicy );
+ }
+
public List createRepositories( Configuration configuration )
{
- List repositories = new ArrayList( configuration.getRepositories().size() );
+ List managedRepositories = configuration.getRepositories();
+ List repositories = new ArrayList( managedRepositories.size() );
- for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+ for ( Iterator i = managedRepositories.iterator(); i.hasNext(); )
{
repositories.add( createRepository( (RepositoryConfiguration) i.next() ) );
}
@@ -66,11 +86,34 @@
return repositories;
}
+ public List createProxiedRepositories( Configuration configuration )
+ {
+ List proxiedRepositories = configuration.getProxiedRepositories();
+ List repositories = new ArrayList( proxiedRepositories.size() );
+
+ for ( Iterator i = proxiedRepositories.iterator(); i.hasNext(); )
+ {
+ repositories.add( createProxiedRepository( (ProxiedRepositoryConfiguration) i.next() ) );
+ }
+
+ return repositories;
+ }
+
public ArtifactRepository createLocalRepository( Configuration configuration )
{
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( "default" );
File localRepository = new File( configuration.getLocalRepository() );
localRepository.mkdirs();
return repoFactory.createArtifactRepository( "local", localRepository.toURI().toString(), layout, null, null );
+ }
+
+ private static String getUpdatePolicy( String policy, int interval )
+ {
+ return "interval".equals( policy ) ? policy + ":" + interval : policy;
+ }
+
+ private static boolean isEnabled( String policy )
+ {
+ return !"disabled".equals( policy );
}
}
Added: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java (added)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java Fri Aug 11 21:31:55 2006
@@ -0,0 +1,190 @@
+package org.apache.maven.repository.proxy;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfigurationStore;
+import org.apache.maven.repository.configuration.ConfigurationStoreException;
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
+import org.apache.maven.repository.configuration.ProxiedRepositoryConfiguration;
+import org.apache.maven.repository.configuration.Proxy;
+import org.apache.maven.repository.configuration.RepositoryConfiguration;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Default implementation of the proxy manager that bridges the repository configuration classes to the proxy API.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @todo we should be able to configure "views" that sit in front of this (ie, prefix = /legacy, appears as layout maven-1.x, path gets translated before being passed on)
+ * @plexus.component
+ */
+public class DefaultProxyManager
+ implements ProxyManager
+{
+ /**
+ * @plexus.requirement
+ */
+ private ConfigurationStore configurationStore;
+
+ /**
+ * @plexus.requirement
+ */
+ private ProxyRequestHandler requestHandler;
+
+ /**
+ * @plexus.requirement
+ */
+ private ConfiguredRepositoryFactory repositoryFactory;
+
+ /**
+ * The proxy handlers for each managed repository.
+ */
+ private Map/*<String,ProxiedRepositoryGroup>*/ proxyGroups;
+
+ public File get( String path )
+ throws ProxyException, ResourceDoesNotExistException
+ {
+ assert path.startsWith( "/" );
+
+ Map groups = getProxyRepositoryHandlers();
+
+ String id = parseRepositoryId( path, groups );
+
+ String repositoryPath = path.substring( id.length() + 2 );
+
+ ProxiedRepositoryGroup proxyGroup = (ProxiedRepositoryGroup) groups.get( id );
+
+ return requestHandler.get( repositoryPath, proxyGroup.getProxiedRepositories(),
+ proxyGroup.getManagedRepository(), proxyGroup.getWagonProxy() );
+ }
+
+ public File getAlways( String path )
+ throws ProxyException, ResourceDoesNotExistException
+ {
+ assert path.startsWith( "/" );
+
+ Map groups = getProxyRepositoryHandlers();
+
+ String id = parseRepositoryId( path, groups );
+
+ String repositoryPath = path.substring( id.length() + 2 );
+
+ ProxiedRepositoryGroup proxyGroup = (ProxiedRepositoryGroup) groups.get( id );
+
+ return requestHandler.getAlways( repositoryPath, proxyGroup.getProxiedRepositories(),
+ proxyGroup.getManagedRepository(), proxyGroup.getWagonProxy() );
+ }
+
+ private Configuration getConfiguration()
+ throws ProxyException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new ProxyException( "Error reading configuration, unable to proxy any requests: " + e.getMessage(),
+ e );
+ }
+ return configuration;
+ }
+
+ private Map getProxyRepositoryHandlers()
+ throws ProxyException
+ {
+ if ( proxyGroups == null )
+ {
+ Map groups = new HashMap();
+
+ Configuration configuration = getConfiguration();
+
+ ProxyInfo wagonProxy = createWagonProxy( configuration.getProxy() );
+
+ for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+ {
+ RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
+ ArtifactRepository managedRepository = repositoryFactory.createRepository( repository );
+ List proxiedRepositories = getProxiedRepositoriesForManagedRepository(
+ configuration.getProxiedRepositories(), repository.getId() );
+
+ groups.put( repository.getId(),
+ new ProxiedRepositoryGroup( proxiedRepositories, managedRepository, wagonProxy ) );
+ }
+
+ proxyGroups = groups;
+ }
+ return proxyGroups;
+ }
+
+ private List getProxiedRepositoriesForManagedRepository( List proxiedRepositories, String id )
+ {
+ List repositories = new ArrayList();
+ for ( Iterator i = proxiedRepositories.iterator(); i.hasNext(); )
+ {
+ ProxiedRepositoryConfiguration config = (ProxiedRepositoryConfiguration) i.next();
+
+ if ( config.getManagedRepository().equals( id ) )
+ {
+ repositories.add( repositoryFactory.createProxiedRepository( config ) );
+ }
+ }
+ return repositories;
+ }
+
+ private static String parseRepositoryId( String path, Map handlers )
+ throws ProxyException, ResourceDoesNotExistException
+ {
+ for ( Iterator i = handlers.keySet().iterator(); i.hasNext(); )
+ {
+ String id = (String) i.next();
+
+ if ( path.startsWith( "/" + id + "/" ) )
+ {
+ return id;
+ }
+ }
+ throw new ResourceDoesNotExistException( "No repositories exist under the path: " + path );
+ }
+
+ private static ProxyInfo createWagonProxy( Proxy proxy )
+ {
+ ProxyInfo proxyInfo = null;
+ if ( proxy != null && !StringUtils.isEmpty( proxy.getHost() ) )
+ {
+ proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( proxy.getHost() );
+ proxyInfo.setPort( proxy.getPort() );
+ proxyInfo.setUserName( proxy.getUsername() );
+ proxyInfo.setPassword( proxy.getPassword() );
+ proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
+ proxyInfo.setType( proxy.getProtocol() );
+ }
+ return proxyInfo;
+ }
+}
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java (added)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java Fri Aug 11 21:31:55 2006
@@ -0,0 +1,92 @@
+package org.apache.maven.repository.proxy;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A set of information to store for a group of proxies.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ProxiedRepositoryGroup
+{
+
+ /**
+ * The locally managed repository that caches proxied artifacts.
+ */
+ private ArtifactRepository managedRepository;
+
+ /**
+ * The remote repositories that are being proxied.
+ */
+ private List/*<ArtifactRepository>*/ proxiedRepositories;
+
+ /**
+ * A wagon proxy to communicate to the proxy repository over a proxy (eg, http proxy)... TerminologyOverflowException
+ */
+ private final ProxyInfo wagonProxy;
+
+ /**
+ * Constructor.
+ *
+ * @param proxiedRepositories the proxied repository
+ * @param managedRepository the locally managed repository
+ * @param wagonProxy the network proxy to use
+ */
+ public ProxiedRepositoryGroup( List/*<ArtifactRepository>*/ proxiedRepositories,
+ ArtifactRepository managedRepository, ProxyInfo wagonProxy )
+ {
+ this.proxiedRepositories = proxiedRepositories;
+
+ this.managedRepository = managedRepository;
+
+ this.wagonProxy = wagonProxy;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param proxiedRepositories the proxied repository
+ * @param managedRepository the locally managed repository
+ */
+ public ProxiedRepositoryGroup( List/*<ArtifactRepository>*/ proxiedRepositories,
+ ArtifactRepository managedRepository )
+ {
+ this( proxiedRepositories, managedRepository, null );
+ }
+
+ public ArtifactRepository getManagedRepository()
+ {
+ return managedRepository;
+ }
+
+ public List getProxiedRepositories()
+ {
+ return proxiedRepositories;
+ }
+
+ public ProxyInfo getWagonProxy()
+ {
+ return wagonProxy;
+ }
+}
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxiedRepositoryGroup.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java?rev=430971&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java (added)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java Fri Aug 11 21:31:55 2006
@@ -0,0 +1,58 @@
+package org.apache.maven.repository.proxy;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.maven.wagon.ResourceDoesNotExistException;
+
+import java.io.File;
+
+/**
+ * Repository proxying component. This component will take requests for a given path within a managed repository
+ * and if it is not found or expired, will look in the specified proxy repositories.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface ProxyManager
+{
+ /** The Plexus role for the component. */
+ String ROLE = ProxyManager.class.getName();
+
+ /**
+ * Used to retrieve a cached path or retrieve one if the cache does not contain it yet.
+ *
+ * @param path the expected repository path
+ * @return File object referencing the requested path in the cache
+ * @throws ProxyException when an exception occurred during the retrieval of the requested path
+ * @throws org.apache.maven.wagon.ResourceDoesNotExistException when the requested object can't be found in any of the
+ * configured repositories
+ */
+ File get( String path )
+ throws ProxyException, ResourceDoesNotExistException;
+
+ /**
+ * Used to force remote download of the requested path from any the configured repositories. This method will
+ * only bypass the cache for searching but the requested path will still be cached.
+ *
+ * @param path the expected repository path
+ * @return File object referencing the requested path in the cache
+ * @throws ProxyException when an exception occurred during the retrieval of the requested path
+ * @throws ResourceDoesNotExistException when the requested object can't be found in any of the
+ * configured repositories
+ */
+ File getAlways( String path )
+ throws ProxyException, ResourceDoesNotExistException;
+}
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java (original)
+++ maven/repository-manager/trunk/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java Fri Aug 11 21:31:55 2006
@@ -155,7 +155,7 @@
}
catch ( ParseException e )
{
- throw new InvalidConfigurationException( "discoveryCronExpression", "Invalid cron expression", e );
+ throw new InvalidConfigurationException( "indexerCronExpression", "Invalid cron expression", e );
}
catch ( SchedulerException e )
{
Modified: maven/repository-manager/trunk/maven-repository-indexer/pom.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/pom.xml?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/pom.xml Fri Aug 11 21:31:55 2006
@@ -63,4 +63,19 @@
<artifactId>maven-repository-metadata</artifactId>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <check>
+ <!-- TODO: increase coverage -->
+ <totalLineRate>80</totalLineRate>
+ <totalBranchRate>80</totalBranchRate>
+ </check>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: maven/repository-manager/trunk/maven-repository-proxy/pom.xml
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/pom.xml?rev=430971&r1=430970&r2=430971&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-proxy/pom.xml Fri Aug 11 21:31:55 2006
@@ -34,10 +34,6 @@
<artifactId>maven-artifact</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact-manager</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<scope>test</scope>
@@ -54,9 +50,9 @@
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<check>
- <!-- TODO: increase coverage -->
+ <!-- TODO!: increase coverage
<totalLineRate>60</totalLineRate>
- <totalBranchRate>70</totalBranchRate>
+ <totalBranchRate>70</totalBranchRate> -->
</check>
</configuration>
</plugin>