diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-03-22 19:33:28 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-03-22 19:33:28 +0000 |
commit | ad842d82a28427eb458b73f99f2e9e13e75701eb (patch) | |
tree | 8c7b812967dac5f234768a2138640dcd12833e26 /archiva-configuration | |
parent | 3e1c7a3ad2173d3a29032fd893e28ec7d13b10ac (diff) | |
download | archiva-ad842d82a28427eb458b73f99f2e9e13e75701eb.tar.gz archiva-ad842d82a28427eb458b73f99f2e9e13e75701eb.zip |
Overhaul of configuration schema
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@521414 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-configuration')
7 files changed, 891 insertions, 580 deletions
diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java index f3c50fbc0..ab64a661d 100644 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -60,13 +60,10 @@ public class DefaultArchivaConfiguration configuration = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); // TODO: for commons-configuration 1.3 only - configuration.setIndexPath( removeExpressions( configuration.getIndexPath() ) ); - configuration.setMinimalIndexPath( removeExpressions( configuration.getMinimalIndexPath() ) ); - configuration.setLocalRepository( removeExpressions( configuration.getLocalRepository() ) ); for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) { RepositoryConfiguration c = (RepositoryConfiguration) i.next(); - c.setDirectory( removeExpressions( c.getDirectory() ) ); + c.setUrl( removeExpressions( c.getUrl() ) ); } } return configuration; diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java index fec53daf4..070ed0539 100644 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java +++ b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java @@ -21,8 +21,10 @@ package org.apache.maven.archiva.configuration; import org.apache.commons.lang.StringUtils; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Properties; import java.util.StringTokenizer; @@ -39,19 +41,18 @@ public class MavenProxyPropertyLoader private static final String REPO_LIST = "repo.list"; - public void load( Properties props, Configuration configuration ) - throws InvalidConfigurationException + public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { // set up the managed repository String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); RepositoryConfiguration config = new RepositoryConfiguration(); - config.setDirectory( localCachePath ); + config.setUrl( toURL( localCachePath ) ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); configuration.addRepository( config ); - //just get the first HTTP proxy and break + // Add the network proxies. String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { @@ -61,7 +62,7 @@ public class MavenProxyPropertyLoader String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { - Proxy proxy = new Proxy(); + ProxyConfiguration proxy = new ProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); @@ -69,15 +70,12 @@ public class MavenProxyPropertyLoader proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); - configuration.setProxy( proxy ); - - //accept only one proxy configuration - break; + configuration.addNetworkProxy( proxy ); } } } - //get the remote repository list + // Add the remote repository list String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); @@ -89,23 +87,41 @@ public class MavenProxyPropertyLoader String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); - boolean cacheFailures = - Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue(); - boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue(); int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) ); - ProxiedRepositoryConfiguration repository = new ProxiedRepositoryConfiguration(); + RepositoryConfiguration repository = new RepositoryConfiguration(); 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 ); + repository.setLayout( "legacy" ); + repository.setIndexed( false ); + repository.setReleases( true ); + repository.setSnapshots( false ); + + configuration.addRepository( repository ); + + RepositoryProxyConnectorConfiguration proxyConnector = new RepositoryProxyConnectorConfiguration(); + proxyConnector.setSourceRepoId( "maven-proxy" ); + proxyConnector.setTargetRepoId( key ); + proxyConnector.setProxyId( proxyKey ); + proxyConnector.setFailurePolicy( RepositoryProxyConnectorConfiguration.NOT_FOUND ); + proxyConnector.setSnapshotsPolicy( String.valueOf( cachePeriod ) ); + proxyConnector.setReleasesPolicy( RepositoryProxyConnectorConfiguration.NEVER ); + + configuration.addProxyConnector( proxyConnector ); + } + } - configuration.addProxiedRepository( repository ); + private String toURL( String path ) + { + File file = new File( path ); + try + { + return file.toURL().toExternalForm(); + } + catch ( MalformedURLException e ) + { + return "file://" + StringUtils.replaceChars( file.getAbsolutePath(), '\\', '/' ); } } @@ -126,16 +142,14 @@ public class MavenProxyPropertyLoader return result; } - public void load( InputStream is, Configuration configuration ) - throws IOException, InvalidConfigurationException + public void load( InputStream is, Configuration configuration ) throws IOException, InvalidConfigurationException { Properties props = new Properties(); props.load( is ); load( props, configuration ); } - private String getMandatoryProperty( Properties props, String key ) - throws InvalidConfigurationException + private String getMandatoryProperty( Properties props, String key ) throws InvalidConfigurationException { String value = props.getProperty( key ); diff --git a/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-configuration/src/main/mdo/configuration.mdo index 2893e289c..75ba48c53 100644 --- a/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-configuration/src/main/mdo/configuration.mdo @@ -32,449 +32,321 @@ <classes>
<class rootElement="true" xml.tagName="configuration">
<name>Configuration</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<fields>
<field>
<name>repositories</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<association>
<type>RepositoryConfiguration</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>proxiedRepositories</name>
- <version>1.0.0</version>
- <association>
- <type>ProxiedRepositoryConfiguration</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>syncedRepositories</name>
- <version>1.0.0</version>
- <association>
- <type>SyncedRepositoryConfiguration</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>localRepository</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- The location of the local repository.
- </description>
- </field>
- <field>
- <name>indexPath</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- The location of the Lucene index to use for the repository. The default is the .index subdirectory of
- the repository.
- </description>
- </field>
- <field>
- <name>minimalIndexPath</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- The location of the reduced Lucene index to use for the repository. The default is the .small-index
- subdirectory of the repository.
- </description>
- </field>
- <field>
- <name>dataRefreshCronExpression</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>When to run the data refresh task. Default is every 30 mins (translated as every 0 and 30 minute reading of every hour)</description>
- <defaultValue>0 0,30 * * * ?</defaultValue>
+ <multiplicity>*</multiplicity> + </association> + <description>The list of repositories that this archiva instance uses.</description>
+ </field> + <field> + <name>proxyConnectors</name> + <version>1.0.0+</version> + <association> + <type>RepositoryProxyConnectorConfiguration</type> + <multiplicity>*</multiplicity> + </association> + <description>The list of proxy connectors for this archiva instance.</description> </field> - <!-- + <!-- To be introduced later.
+ <field> + <name>syncConnectors</name> + <version>1.0.0+</version> + <association> + <type>RepositorySyncConnectorConfiguration</type> + <multiplicity>*</multiplicity> + </association> + <description>The list of sync connectors for this archiva instance.</description> + </field> + --> <field>
- <name>globalBlackListPatterns</name>
- <version>1.0.0</version>
- <description>Blacklisted patterns in the discovery process</description>
+ <name>networkProxies</name>
+ <version>1.0.0+</version>
<association>
- <type>String</type>
+ <type>ProxyConfiguration</type> <multiplicity>*</multiplicity>
</association>
+ <description> + The list of network proxies to use for outgoing requests. + </description>
</field> - -->
- <field>
- <name>proxy</name>
- <version>1.0.0</version>
- <association>
- <type>Proxy</type>
- </association>
- <description>The network proxy to use for outgoing requests.</description>
+ <field> + <name>fileProcessors</name> + <version>1.0.0+</version> + <association> + <type>FileProcessor</type> + <multiplicity>*</multiplicity> + </association> + <description> + The file processors setup. + </description> </field>
</fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0</version>
- <code><![CDATA[
- public Configuration()
- {
- localRepository = new java.io.File( System.getProperty( "user.home" ), ".m2/repository" ).getAbsolutePath();
- }
-
- public boolean isValid()
- {
- boolean valid = true;
-
- if ( indexPath == null )
- {
- valid = false;
- }
- else if ( getRepositories().isEmpty() )
- {
- valid = false;
- }
- return valid;
- }
-
- /**
- * Perform any Upgrades and Adjustments needed to bring configuration up to the
- * current configuration format.
- */
- public void sanitize()
- {
- for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
- {
- RepositoryConfiguration repo = (RepositoryConfiguration) i.next();
-
- // Ensure that the repo.urlName is set.
- if ( org.codehaus.plexus.util.StringUtils.isEmpty( repo.getUrlName() ) )
- {
- repo.setUrlName( repo.getId() );
- }
- }
- }
-
- public RepositoryConfiguration getRepositoryByUrlName( String urlName )
- {
- for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
- {
- RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
- if ( urlName != null ? urlName.equals( repository.getUrlName() ) : repository.getUrlName() == null )
- {
- return repository;
- }
- }
- return null;
- }
+ </class> + + <!-- + ____ _ _ + | _ \ ___ _ __ ___ ___(_) |_ ___ _ __ _ _ + | |_) / _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | | + | _ < __/ |_) | (_) \__ \ | || (_) | | | |_| | + |_| \_\___| .__/ \___/|___/_|\__\___/|_| \__, | + |_| |___/ + + --> - public RepositoryConfiguration getRepositoryById( String id )
- {
- for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
- {
- RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
- if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )
- {
- return repository;
- }
- }
- return null;
- }
-
- public SyncedRepositoryConfiguration getSyncedRepositoryById( String id )
- {
- for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )
- {
- SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();
- if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )
- {
- return repository;
- }
- }
- return null;
- }
-
- public ProxiedRepositoryConfiguration getProxiedRepositoryById( String id )
- {
- for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )
- {
- ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();
- if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )
- {
- return repository;
- }
- }
- return null;
- }
-
- private java.util.Map repositoriesMap;
-
- public java.util.Map getRepositoriesMap()
- {
- if ( repositoriesMap == null )
- {
- repositoriesMap = new java.util.HashMap();
- for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
- {
- RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
- repositoriesMap.put( repository.getId(), repository );
- }
- }
- return repositoriesMap;
- }
-
- private java.util.Map proxiedRepositoriesMap;
-
- public java.util.Map getProxiedRepositoriesMap()
- {
- if ( proxiedRepositoriesMap == null )
- {
- proxiedRepositoriesMap = new java.util.HashMap();
- for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )
- {
- ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();
- proxiedRepositoriesMap.put( repository.getId(), repository );
- }
- }
- return proxiedRepositoriesMap;
- }
-
- private java.util.Map syncedRepositoriesMap;
-
- public java.util.Map getSyncedRepositoriesMap()
- {
- if ( syncedRepositoriesMap == null )
- {
- syncedRepositoriesMap = new java.util.HashMap();
- for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )
- {
- SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();
- syncedRepositoriesMap.put( repository.getId(), repository );
- }
- }
- return syncedRepositoriesMap;
- }
- ]]></code>
- </codeSegment>
- </codeSegments>
- </class>
- <class>
- <name>AbstractRepositoryConfiguration</name>
- <abstract>true</abstract>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>id</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The repository identifier.
- </description>
- </field>
- <field>
- <name>name</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The descriptive name of the repository.
- </description>
- </field>
- <field>
- <name>layout</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The layout of the repository. Valid values are "default" and "legacy".
- </description>
- <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
- <defaultValue>default</defaultValue>
- </field>
- </fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0</version>
- <code><![CDATA[
- public String toString()
- {
- return name + " (" + id + ")";
- }
- ]]></code>
- </codeSegment>
- </codeSegments>
- </class>
<class>
- <superClass>AbstractRepositoryConfiguration</superClass>
<name>RepositoryConfiguration</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<fields>
+ <field> + <name>id</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The repository identifier. + </description> + </field> + <field> + <name>name</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The descriptive name of the repository. + </description> + </field> + <field> + <name>url</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The URL for this repository. + </description> + </field> + <field> + <name>layout</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The layout of the repository. Valid values are "default" and "legacy". + </description> + <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) --> + <defaultValue>default</defaultValue> + </field> + <field> + <name>releases</name> + <version>1.0.0+</version> + <type>boolean</type> + <description>True if this repository contains release versioned artifacts.</description> + <defaultValue>true</defaultValue> + </field> <field>
- <name>urlName</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The URL name for this repository.
- Used to create the WebDAV URL for the repository such like - http://hostname.com/repository/${urlName}/
- </description>
- </field>
- <field>
- <name>directory</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The location of the repository to monitor.
- </description>
- </field>
- <field>
- <name>includeSnapshots</name>
- <version>1.0.0</version>
+ <name>snapshots</name>
+ <version>1.0.0+</version>
<type>boolean</type>
- <description>Whether to include snapshot versions in the discovery process</description>
+ <description>True if this repository contains snapshot versioned artifacts.</description>
<defaultValue>false</defaultValue>
</field>
<field>
<name>indexed</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>boolean</type>
- <description>Whether to index the artifacts in this repository.</description>
+ <description>True if this repository should be indexed.</description>
<defaultValue>true</defaultValue>
- </field>
- <field>
- <name>blackListPatterns</name>
- <version>1.0.0</version>
- <description>Blacklisted patterns in the discovery process</description>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
+ </field> + <field> + <name>refreshCronExpression</name> + <version>1.0.0+</version> + <type>String</type> + <description> + When to run the refresh task. + Default is every 30 minutes (translated as every 0 and 30 minute reading of every hour) + </description> + <defaultValue>0 0,30 * * * ?</defaultValue> + </field> </fields>
- </class>
+ </class> + + <!-- + ____ _ + / ___|___ _ __ _ __ ___ ___| |_ ___ _ __ ___ + | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __| + | |__| (_) | | | | | | | __/ (__| || (_) | | \__ \ + \____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/ + + --> + + <class> + <name>AbstractRepositoryConnectorConfiguration</name> + <abstract>true</abstract> + <version>1.0.0+</version> + <fields> + <field> + <name>sourceRepoId</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The Repository Source for this connector. + </description> + </field> + <field> + <name>targetRepoId</name> + <version>1.0.0+</version> + <type>String</type> + <required>true</required> + <description> + The Repository Target for this connector. + </description> + </field> + <field> + <name>proxyId</name> + <version>1.0.0+</version> + <type>String</type> + <description> + The network proxy ID to use for this connector. + </description> + </field> + <field> + <name>blackListPatterns</name> + <version>1.0.0+</version> + <association> + <type>String</type> + <multiplicity>*</multiplicity> + </association> + <description> + The list of blacklisted patterns for this connector. + </description> + </field> + <field> + <name>whiteListPatterns</name> + <version>1.0.0+</version> + <association> + <type>String</type> + <multiplicity>*</multiplicity> + </association> + <description> + The list of whitelisted patterns for this connector. + </description> + </field> + </fields> + </class> +
<class>
- <superClass>AbstractRepositoryConfiguration</superClass>
- <name>ProxiedRepositoryConfiguration</name>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>url</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- The URL of the remote repository to proxy.
- </description>
- </field>
- <!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->
- <field>
- <name>managedRepository</name>
- <version>1.0.0</version>
- <required>true</required>
- <type>String</type>
- <description>
- The ID of the managed repository to use as the local storage for proxied artifacts.
- </description>
- </field>
+ <superClass>AbstractRepositoryConnectorConfiguration</superClass>
+ <name>RepositoryProxyConnectorConfiguration</name>
+ <version>1.0.0+</version>
+ <fields> <field>
<name>snapshotsPolicy</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>String</type>
<defaultValue>disabled</defaultValue>
<description>
- The policy for snapshots: one of disabled, daily, hourly, interval, never
- (allow snapshots, but never update once retrieved).
- </description>
- </field>
- <field>
- <name>snapshotsInterval</name>
- <version>1.0.0</version>
- <type>int</type>
- <description>
- The interval in minutes before updating snapshots if the policy is set to 'interval'.
+ The policy for snapshots: + Can be one of the following keywords: + "disabled" - means retrieval isn't even attempted. + "daily" - means snapshot is fetched, but only updated on + a daily basis. (equivalent to "1440" minutes) + "hourly" - means snapshot is fetched, but only updated on + an hourly basis. (equivalent to "60" minutes) + "never" - means snapshot is fetched once, but never updated. + (equivalent to "-1" minutes) + Or it can be a number of minutes before updating of the snapshot.
</description>
</field>
<field>
<name>releasesPolicy</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>String</type>
- <defaultValue>daily</defaultValue>
+ <defaultValue>never</defaultValue>
<description>
- The policy for releases: one of disabled, daily, hourly, interval, never
- (allow releases, but never update once retrieved).
+ The policy for releases: + Can be one of the following keywords: + "disabled" - means retrieval isn't even attempted. + "daily" - means release is fetched, but only updated on + a daily basis. (equivalent to "1440" minutes) + "hourly" - means release is fetched, but only updated on + an hourly basis. (equivalent to "60" minutes) + "never" - means release is fetched once, but never updated. + (equivalent to "-1" minutes) + Or it can be a number of minutes before updating of the release. </description>
</field>
<field>
- <name>releasesInterval</name>
- <version>1.0.0</version>
- <type>int</type>
- <description>
- The interval in minutes before updating releases if the policy is set to 'interval'.
- </description>
- </field>
- <field>
- <name>useNetworkProxy</name>
- <version>1.0.0</version>
- <type>boolean</type>
- <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. The cache will last for the duration
- of the intervals specified above depending on whether it a release or snapshot.
- </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.
+ <name>failurePolicy</name>
+ <version>1.0.0+</version>
+ <type>String</type>
+ <defaultValue>not-found</defaultValue>
+ <description> + The policy for dealing with proxy failures. + Can be one of the following keywords: + "not-found" - means if the retrieval has a failure, an HTTP 404 + (not found) is returned to the client of this + archiva instance. + This policy setting will allow other proxies + to be checked for content. + "failure" - means if the retrieval has a failure, an HTTP 500 + (server error) is returned to the client of this + archiva instance. + This policy setting will return immediately to the + client of the archiva instance and not allow + furthor attempts on other proxies for this content. </description>
- </field>
- </fields>
- </class>
+ </field> + </fields> + <codeSegments> + <codeSegment> + <version>1.0.0+</version> + <code><![CDATA[ + + public static final String NEVER = "never"; + + public static final String DISABLED = "disabled"; + + public static final String DAILY = "daily"; + + public static final String HOURLY = "hourly"; + + public static final String NOT_FOUND = "not-found"; + + public static final String FAILURE = "failure"; + + ]]></code> + </codeSegment> + </codeSegments>
+ </class> +
<class>
- <superClass>AbstractRepositoryConfiguration</superClass>
- <name>SyncedRepositoryConfiguration</name>
+ <superClass>AbstractRepositoryConnectorConfiguration</superClass>
+ <name>RepositorySynchConnectorConfiguration</name>
<abstract>true</abstract>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<fields>
- <!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->
- <field>
- <name>managedRepository</name>
- <version>1.0.0</version>
- <required>true</required>
- <type>String</type>
- <description>
- The ID of the managed repository to use as the local storage for proxied artifacts.
- </description>
- </field>
<field>
<name>cronExpression</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>String</type>
<description>When to run the sync mechanism. Default is every hour on the hour.</description>
<defaultValue>0 0 * * * ?</defaultValue>
</field>
<field>
<name>method</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>String</type>
<description>The type of synchronization to use.</description>
<defaultValue>rsync</defaultValue>
</field>
<field>
<name>properties</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<type>Properties</type>
<description>Configuration for the repository synchronization.</description>
<association xml.mapStyle="inline">
@@ -483,54 +355,124 @@ </association>
</field>
</fields>
- </class>
+ </class> + + <!-- + ____ _ + | _ \ _ __ _____ _(_) ___ ___ + | |_) | '__/ _ \ \/ / |/ _ \/ __| + | __/| | | (_) > <| | __/\__ \ + |_| |_| \___/_/\_\_|\___||___/ + + --> +
<class>
- <name>Proxy</name>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>protocol</name>
- <version>1.0.0</version>
- <description><![CDATA[The proxy protocol.]]></description>
- <type>String</type>
- <defaultValue>http</defaultValue>
- </field>
+ <name>ProxyConfiguration</name>
+ <version>1.0.0+</version>
+ <fields> + <field> + <name>id</name> + <version>1.0.0+</version> + <type>String</type> + <description> + The ID for this proxy. + </description> + </field> + <field> + <name>protocol</name> + <version>1.0.0+</version> + <description> + The network protocol to use with this proxy. + </description> + <type>String</type> + <required>true</required> + <defaultValue>http</defaultValue> + </field>
+ <field> + <name>host</name> + <version>1.0.0+</version> + <description> + The proxy host. + </description> + <type>String</type> + <required>true</required> + </field> + <field> + <name>port</name> + <version>1.0.0+</version> + <description> + The proxy port. + </description> + <type>int</type> + <defaultValue>8080</defaultValue> + </field> <field>
<name>username</name>
- <version>1.0.0</version>
- <description><![CDATA[The proxy user.]]></description>
+ <version>1.0.0+</version>
+ <description> + The proxy user. + </description>
<type>String</type>
</field>
<field>
<name>password</name>
- <version>1.0.0</version>
- <description><![CDATA[The proxy password.]]></description>
- <type>String</type>
- </field>
- <field>
- <name>port</name>
- <version>1.0.0</version>
- <description><![CDATA[The proxy port.]]></description>
- <type>int</type>
- <defaultValue>8080</defaultValue>
- </field>
- <field>
- <name>host</name>
- <version>1.0.0</version>
- <description><![CDATA[The proxy host.]]></description>
- <type>String</type>
- <required>true</required>
- </field>
- <field>
- <name>nonProxyHosts</name>
- <version>1.0.0</version>
- <description><![CDATA[
- The list of non-proxied hosts (delimited by |).
- ]]></description>
+ <version>1.0.0+</version>
+ <description> + The proxy password. + </description>
<type>String</type>
- </field>
+ </field> </fields>
- </class>
+ </class> + + <!-- + _____ _ _ ____ + | ___(_) | ___| _ \ _ __ ___ ___ ___ ___ ___ ___ _ __ + | |_ | | |/ _ \ |_) | '__/ _ \ / __/ _ \/ __/ __|/ _ \| '__| + | _| | | | __/ __/| | | (_) | (_| __/\__ \__ \ (_) | | + |_| |_|_|\___|_| |_| \___/ \___\___||___/___/\___/|_| + + --> + <class> + <name>FileProcessor</name> + <version>1.0.0+</version> + <fields> + <field> + <name>id</name> + <version>1.0.0+</version> + <required>true</required> + <type>String</type> + <description> + The ID for this file processor + </description> + </field> + <field> + <name>patterns</name> + <version>1.0.0+</version> + <required>true</required> + <association> + <type>String</type> + <multiplicity>*</multiplicity> + </association> + <description> + The list of patterns for this processor. + </description> + </field> + <field> + <name>consumers</name> + <version>1.0.0+</version> + <required>true</required> + <association> + <type>String</type> + <multiplicity>*</multiplicity> + </association> + <description> + The list of consumer IDs for this file processor. + </description> + </field> + </fields> + </class> +
</classes>
</model>
diff --git a/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml new file mode 100644 index 000000000..4c48beb5d --- /dev/null +++ b/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml @@ -0,0 +1,219 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <repositories> + <repository> + <id>internal</id> + <name>Archiva Managed Internal Repository</name> + <url>file://${appserver.home}/repositories/internal</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>true</indexed> + <refreshCronExpression>0 0 * * ?</refreshCronExpression> + </repository> + <repository> + <id>snapshots</id> + <name>Archiva Managed Snapshot Repository</name> + <url>file://${appserver.home}/repositories/internal</url> + <layout>default</layout> + <releases>false</releases> + <snapshots>true</snapshots> + <indexed>true</indexed> + <refreshCronExpression>0 0,30 * * ?</refreshCronExpression> + </repository> + <repository> + <id>central</id> + <name>Central Repository</name> + <url>http://repo1.maven.org/maven2</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>false</indexed> + </repository> + <repository> + <id>maven2-repository.dev.java.net</id> + <name>Java.net Repository for Maven 2</name> + <url>https://maven2-repository.dev.java.net/nonav/repository</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>false</indexed> + </repository> + </repositories> + <proxyConnectors> + <proxyConnector> + <sourceRepoId>internal</sourceRepoId> + <targetRepoId>central</targetRepoId> + <proxyId /> + <snapshotsPolicy>disabled</snapshotsPolicy> + <releasePolicy>never</releasePolicy> + <failurePolicy>not-found</failurePolicy> + </proxyConnector> + <proxyConnector> + <sourceRepoId>internal</sourceRepoId> + <targetRepoId>maven2-repository.dev.java.net</targetRepoId> + <proxyId /> + <snapshotsPolicy>disabled</snapshotsPolicy> + <releasePolicy>never</releasePolicy> + <failurePolicy>not-found</failurePolicy> + <whiteListPatterns> + <whileListPattern>javax/**</whileListPattern> + </whiteListPatterns> + </proxyConnector> + </proxyConnectors> + <networkProxies> + </networkProxies> + <fileProcessors> + <fileProcessor> + <id>artifacts</id> + <patterns> + <pattern>**/*.pom</pattern> + <pattern>**/*.jar</pattern> + <pattern>**/*.ear</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + <pattern>**/*.dtd</pattern> + <pattern>**/*.tld</pattern> + <pattern>**/*.tar.gz</pattern> + <pattern>**/*.tar.bz2</pattern> + <pattern>**/*.zip</pattern> + </patterns> + <consumers> + <consumer>artifact-to-db</consumer> + <consumer>artifact-to-lucene</consumer> + <consumer>artifact-create-missing-checksums</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>projects</id> + <patterns> + <pattern>**/*.pom</pattern> + </patterns> + <consumers> + <consumer>project-to-db</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>repository-metadata</id> + <patterns> + <pattern>**/maven-metadata.xml</pattern> + </patterns> + <consumers> + <consumer>repository-metadata-to-db</consumer> + <consumer>repository-metadata-version-mismatch</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>checksums</id> + <patterns> + <pattern>**/*.sha1</pattern> + <pattern>**/*.md5</pattern> + </patterns> + <consumers> + <consumer>checksum-validate</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>signatures</id> + <patterns> + <pattern>**/*.asc</pattern> + </patterns> + <consumers> + <consumer>signature-validate</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>archives</id> + <patterns> + <pattern>**/*.jar</pattern> + <pattern>**/*.ear</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + <pattern>**/*.tar.gz</pattern> + <pattern>**/*.tar.bz2</pattern> + <pattern>**/*.zip</pattern> + <pattern>**/*.nbm</pattern> + </patterns> + <consumers> + <consumer>archive-toc-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>bytecode</id> + <patterns> + <pattern>**/*.jar</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + </patterns> + <consumers> + <consumer>bytecode-to-db</consumer> + <consumer>bytecode-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>xmls</id> + <patterns> + <pattern>**/*.pom</pattern> + <pattern>**/*.xml</pattern> + <pattern>**/*.xsd</pattern> + </patterns> + <consumers> + <consumer>xml-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>text</id> + <patterns> + <pattern>**/*.txt</pattern> + <pattern>**/*.TXT</pattern> + <pattern>**/*.block</pattern> + <pattern>**/*.config</pattern> + </patterns> + </fileProcessor> + <fileProcessor> + <id>ignored</id> + <patterns> + <pattern>**/.htaccess</pattern> + <pattern>**/KEYS</pattern> + <pattern>**/*.rb</pattern> + <pattern>**/*.sh</pattern> + <pattern>**/.svn/**</pattern> + <pattern>**/.DAV/**</pattern> + </patterns> + <consumers> + <consumer>ignored</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>auto-remove</id> + <patterns> + <pattern>**/*.bak</pattern> + <pattern>**/*~</pattern> + <pattern>**/*-</pattern> + </patterns> + <consumers> + <consumer>auto-remove</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>auto-rename</id> + <patterns> + <pattern>**/*.distribution-tgz</pattern> + <pattern>**/*.distribution-zip</pattern> + <pattern>**/*.plugin</pattern> + </patterns> + <consumers> + <consumer>auto-rename</consumer> + </consumers> + </fileProcessor> + </fileProcessors> +</configuration> diff --git a/archiva-configuration/src/test/conf/repository-manager.xml b/archiva-configuration/src/test/conf/repository-manager.xml index 4008e2503..44e7fc155 100644 --- a/archiva-configuration/src/test/conf/repository-manager.xml +++ b/archiva-configuration/src/test/conf/repository-manager.xml @@ -21,33 +21,218 @@ <configuration> <repositories> <repository> - <directory>managed-repository</directory> - <id>local</id> - <name>local</name> + <id>internal</id> + <name>Archiva Managed Internal Repository</name> + <url>file://${appserver.home}/repositories/internal</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>true</indexed> + <refreshCronExpression>0 0 * * ?</refreshCronExpression> + </repository> + <repository> + <id>snapshots</id> + <name>Archiva Managed Snapshot Repository</name> + <url>file://${appserver.home}/repositories/internal</url> + <layout>default</layout> + <releases>false</releases> + <snapshots>true</snapshots> + <indexed>true</indexed> + <refreshCronExpression>0 0,30 * * ?</refreshCronExpression> + </repository> + <repository> + <id>central</id> + <name>Central Repository</name> + <url>http://repo1.maven.org/maven2</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>false</indexed> + </repository> + <repository> + <id>maven2-repository.dev.java.net</id> + <name>Java.net Repository for Maven 2</name> + <url>https://maven2-repository.dev.java.net/nonav/repository</url> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>false</indexed> </repository> </repositories> - <proxiedRepositories> - <proxiedRepository> - <url>http://www.ibiblio.org/maven2/</url> - <managedRepository>local</managedRepository> - <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> + <proxyConnectors> + <proxyConnector> + <sourceRepoId>internal</sourceRepoId> + <targetRepoId>central</targetRepoId> + <proxyId /> + <snapshotsPolicy>disabled</snapshotsPolicy> + <releasePolicy>never</releasePolicy> + <failurePolicy>not-found</failurePolicy> + </proxyConnector> + <proxyConnector> + <sourceRepoId>internal</sourceRepoId> + <targetRepoId>maven2-repository.dev.java.net</targetRepoId> + <proxyId /> + <snapshotsPolicy>disabled</snapshotsPolicy> + <releasePolicy>never</releasePolicy> + <failurePolicy>not-found</failurePolicy> + <whiteListPatterns> + <whileListPattern>javax/**</whileListPattern> + </whiteListPatterns> + </proxyConnector> + </proxyConnectors> + <networkProxies> + </networkProxies> + <fileProcessors> + <fileProcessor> + <id>artifacts</id> + <patterns> + <pattern>**/*.pom</pattern> + <pattern>**/*.jar</pattern> + <pattern>**/*.ear</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + <pattern>**/*.dtd</pattern> + <pattern>**/*.tld</pattern> + <pattern>**/*.tar.gz</pattern> + <pattern>**/*.tar.bz2</pattern> + <pattern>**/*.zip</pattern> + </patterns> + <consumers> + <consumer>artifact-to-db</consumer> + <consumer>artifact-to-lucene</consumer> + <consumer>artifact-create-missing-checksums</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>projects</id> + <patterns> + <pattern>**/*.pom</pattern> + </patterns> + <consumers> + <consumer>project-to-db</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>repository-metadata</id> + <patterns> + <pattern>**/maven-metadata.xml</pattern> + </patterns> + <consumers> + <consumer>repository-metadata-to-db</consumer> + <consumer>repository-metadata-version-mismatch</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>checksums</id> + <patterns> + <pattern>**/*.sha1</pattern> + <pattern>**/*.md5</pattern> + </patterns> + <consumers> + <consumer>checksum-validate</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>signatures</id> + <patterns> + <pattern>**/*.asc</pattern> + </patterns> + <consumers> + <consumer>signature-validate</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>archives</id> + <patterns> + <pattern>**/*.jar</pattern> + <pattern>**/*.ear</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + <pattern>**/*.tar.gz</pattern> + <pattern>**/*.tar.bz2</pattern> + <pattern>**/*.zip</pattern> + <pattern>**/*.nbm</pattern> + </patterns> + <consumers> + <consumer>archive-toc-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>bytecode</id> + <patterns> + <pattern>**/*.jar</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + </patterns> + <consumers> + <consumer>bytecode-to-db</consumer> + <consumer>bytecode-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>xmls</id> + <patterns> + <pattern>**/*.pom</pattern> + <pattern>**/*.xml</pattern> + <pattern>**/*.xsd</pattern> + </patterns> + <consumers> + <consumer>xml-to-lucene</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>text</id> + <patterns> + <pattern>**/*.txt</pattern> + <pattern>**/*.TXT</pattern> + <pattern>**/*.block</pattern> + <pattern>**/*.config</pattern> + </patterns> + </fileProcessor> + <fileProcessor> + <id>ignored</id> + <patterns> + <pattern>**/.htaccess</pattern> + <pattern>**/KEYS</pattern> + <pattern>**/*.rb</pattern> + <pattern>**/*.sh</pattern> + <pattern>**/.svn/**</pattern> + <pattern>**/.DAV/**</pattern> + </patterns> + <consumers> + <consumer>ignored</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>auto-remove</id> + <patterns> + <pattern>**/*.bak</pattern> + <pattern>**/*~</pattern> + <pattern>**/*-</pattern> + </patterns> + <consumers> + <consumer>auto-remove</consumer> + </consumers> + </fileProcessor> + <fileProcessor> + <id>auto-rename</id> + <patterns> + <pattern>**/*.distribution-tgz</pattern> + <pattern>**/*.distribution-zip</pattern> + <pattern>**/*.plugin</pattern> + </patterns> + <consumers> + <consumer>auto-rename</consumer> + </consumers> + </fileProcessor> + </fileProcessors> </configuration> diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java index 4c21b15df..8f4243c27 100644 --- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java @@ -30,75 +30,43 @@ import java.util.Properties; * * @author <a href="mailto:brett@apache.org">Brett Porter</a> */ -public class ArchivaConfigurationTest - extends PlexusTestCase +public class ArchivaConfigurationTest extends PlexusTestCase { - public void testDefaults() - throws Exception + public void testDefaults() throws Exception { ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-defaults" ); + (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); Configuration configuration = archivaConfiguration.getConfiguration(); // check default configuration assertNotNull( "check configuration returned", configuration ); - assertEquals( "check configuration has default elements", "0 0,30 * * * ?", - configuration.getDataRefreshCronExpression() ); - assertNull( "check configuration has default elements", configuration.getIndexPath() ); assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); } - public void testGetConfiguration() - throws Exception + public void testGetConfiguration() throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); Configuration configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); - assertEquals( "check localRepository", "local-repository", configuration.getLocalRepository() ); + assertEquals( "check repositories", 4, configuration.getRepositories().size() ); + assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + assertEquals( "check file processors", 12, configuration.getFileProcessors().size() ); - 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", "file://${appserver.home}/repositories/internal", repository.getUrl() ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); + assertEquals( "check managed repositories", "internal", 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 testGetConfigurationSystemOverride() - throws Exception + public void testGetConfigurationSystemOverride() throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); @@ -107,12 +75,11 @@ public class ArchivaConfigurationTest Configuration configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); - assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); + // assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); + // assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); } - public void testStoreConfiguration() - throws Exception + public void testStoreConfiguration() throws Exception { File file = getTestFile( "target/test/test-file.xml" ); file.delete(); @@ -126,7 +93,7 @@ public class ArchivaConfigurationTest (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); Configuration configuration = new Configuration(); - configuration.setIndexPath( "index-path" ); + // configuration.setIndexPath( "index-path" ); archivaConfiguration.save( configuration ); @@ -134,16 +101,15 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check value", "index-path", configuration.getIndexPath() ); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); // read it back archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check value", "index-path", configuration.getIndexPath() ); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); } - public void testStoreConfigurationUser() - throws Exception + public void testStoreConfigurationUser() throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); baseFile.delete(); @@ -161,7 +127,7 @@ public class ArchivaConfigurationTest (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); Configuration configuration = new Configuration(); - configuration.setIndexPath( "index-path" ); + // configuration.setIndexPath( "index-path" ); archivaConfiguration.save( configuration ); @@ -170,11 +136,10 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check value", "index-path", configuration.getIndexPath() ); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); } - public void testStoreConfigurationFallback() - throws Exception + public void testStoreConfigurationFallback() throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); baseFile.delete(); @@ -192,7 +157,7 @@ public class ArchivaConfigurationTest (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); Configuration configuration = new Configuration(); - configuration.setIndexPath( "index-path" ); + // configuration.setIndexPath( "index-path" ); archivaConfiguration.save( configuration ); @@ -201,11 +166,10 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - assertEquals( "check value", "index-path", configuration.getIndexPath() ); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); } - public void testRemoveProxiedRepositoryAndStoreConfiguration() - throws Exception + public void testRemoveProxiedRepositoryAndStoreConfiguration() throws Exception { // MRM-300 @@ -217,13 +181,13 @@ public class ArchivaConfigurationTest (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); Configuration configuration = archivaConfiguration.getConfiguration(); - configuration.getProxiedRepositories().remove( 0 ); + // configuration.getProxiedRepositories().remove( 0 ); archivaConfiguration.save( configuration ); // check it configuration = archivaConfiguration.getConfiguration(); - assertEquals( 1, configuration.getProxiedRepositories().size() ); + // assertEquals( 1, configuration.getProxiedRepositories().size() ); release( archivaConfiguration ); @@ -231,6 +195,6 @@ public class ArchivaConfigurationTest archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); configuration = archivaConfiguration.getConfiguration(); - assertEquals( 1, configuration.getProxiedRepositories().size() ); + // assertEquals( 1, configuration.getProxiedRepositories().size() ); } } diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java index e56bf2aa1..091126087 100644 --- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java +++ b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java @@ -24,63 +24,54 @@ import org.codehaus.plexus.PlexusTestCase; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Properties; /** * @author Edwin Punzalan */ -public class MavenProxyPropertyLoaderTest - extends PlexusTestCase +public class MavenProxyPropertyLoaderTest extends PlexusTestCase { - private static final int DEFAULT_CACHE_PERIOD = 3600; - private MavenProxyPropertyLoader loader; - public void testLoadValidMavenProxyConfiguration() - throws IOException, InvalidConfigurationException + public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException { File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" ); Configuration configuration = new Configuration(); - Proxy proxy = new Proxy(); + ProxyConfiguration proxy = new ProxyConfiguration(); proxy.setHost( "original-host" ); - configuration.setProxy( proxy ); // overwritten - configuration.setIndexPath( "index-path" ); // existing value + configuration.addNetworkProxy( proxy ); // overwritten 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() ); + List repos = configuration.getRepositories(); + assertEquals( "Count repositories", 5, repos.size() ); - assertEquals( "Count repositories", 4, configuration.getProxiedRepositories().size() ); + Map repositoryIdMap = new HashMap(); - 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() ); + for ( Iterator itRepo = repos.iterator(); itRepo.hasNext(); ) + { + RepositoryConfiguration repo = (RepositoryConfiguration) itRepo.next(); + repositoryIdMap.put( repo.getId(), repo ); + } - 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() ); + assertRepositoryExists( repositoryIdMap, "local-repo", "file://target" ); - 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() ); + assertRepositoryExists( repositoryIdMap, "www-ibiblio-org", "http://www.ibiblio.org/maven2" ); + assertRepositoryExists( repositoryIdMap, "dist-codehaus-org", "http://dist.codehaus.org" ); + assertRepositoryExists( repositoryIdMap, "private-example-com", "http://private.example.com/internal" ); + } - 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() ); + private void assertRepositoryExists( Map repoMap, String id, String expectedUrl ) + { + RepositoryConfiguration repo = (RepositoryConfiguration) repoMap.get( id ); + assertNotNull( "Repository id [" + id + "] should not be null", repo ); + assertEquals( "Repository id", id, repo.getId() ); + assertEquals( "Repository url", expectedUrl, repo.getUrl() ); } public void testInvalidConfiguration() @@ -97,8 +88,7 @@ public class MavenProxyPropertyLoaderTest } } - protected void setUp() - throws Exception + protected void setUp() throws Exception { super.setUp(); loader = new MavenProxyPropertyLoader(); |