mirror of https://github.com/apache/archiva.git
Reorganization of model for policy maps and archiva-policies
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@528539 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68a076bf26
commit
08223ca0ec
|
@ -29,6 +29,15 @@
|
|||
<artifactId>archiva-configuration</artifactId>
|
||||
<name>Archiva Base :: Configuration</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-policies</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-api</artifactId>
|
||||
|
|
|
@ -20,11 +20,12 @@ package org.apache.maven.archiva.configuration;
|
|||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
|
||||
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;
|
||||
|
@ -41,13 +42,14 @@ 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.setUrl( toURL( localCachePath ) );
|
||||
config.setUrl( PathUtil.toUrl( localCachePath ) );
|
||||
config.setName( "Imported Maven-Proxy Cache" );
|
||||
config.setId( "maven-proxy" );
|
||||
configuration.addRepository( config );
|
||||
|
@ -97,31 +99,20 @@ public class MavenProxyPropertyLoader
|
|||
repository.setIndexed( false );
|
||||
repository.setReleases( true );
|
||||
repository.setSnapshots( false );
|
||||
|
||||
|
||||
configuration.addRepository( repository );
|
||||
|
||||
RepositoryProxyConnectorConfiguration proxyConnector = new RepositoryProxyConnectorConfiguration();
|
||||
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
|
||||
proxyConnector.setSourceRepoId( "maven-proxy" );
|
||||
proxyConnector.setTargetRepoId( key );
|
||||
proxyConnector.setProxyId( proxyKey );
|
||||
// TODO: convert cachePeriod to closest "daily" or "hourly"
|
||||
proxyConnector.setSnapshotsPolicy( "daily" );
|
||||
proxyConnector.setReleasesPolicy( "never" );
|
||||
|
||||
configuration.addProxyConnector( proxyConnector );
|
||||
}
|
||||
}
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS,
|
||||
SnapshotsPolicy.DAILY );
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES,
|
||||
ReleasesPolicy.IGNORED );
|
||||
|
||||
private String toURL( String path )
|
||||
{
|
||||
File file = new File( path );
|
||||
try
|
||||
{
|
||||
return file.toURL().toExternalForm();
|
||||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
return "file://" + StringUtils.replaceChars( file.getAbsolutePath(), '\\', '/' );
|
||||
configuration.addProxyConnector( proxyConnector );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,14 +133,16 @@ 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 );
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<name>proxyConnectors</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>RepositoryProxyConnectorConfiguration</type>
|
||||
<type>ProxyConnectorConfiguration</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>The list of proxy connectors for this archiva instance.</description>
|
||||
|
@ -57,7 +57,7 @@
|
|||
<name>syncConnectors</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>RepositorySyncConnectorConfiguration</type>
|
||||
<type>SyncConnectorConfiguration</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>The list of sync connectors for this archiva instance.</description>
|
||||
|
@ -307,76 +307,97 @@
|
|||
The list of whitelisted patterns for this connector.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<superClass>AbstractRepositoryConnectorConfiguration</superClass>
|
||||
<name>RepositoryProxyConnectorConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<fields>
|
||||
<field>
|
||||
<name>snapshotsPolicy</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<defaultValue>disabled</defaultValue>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<p>
|
||||
The policy for snapshots, one of the following:
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#DISABLED disabled},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#DAILY daily},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#HOURLY hourly},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#ONCE once}
|
||||
</p>
|
||||
|
||||
@see org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy
|
||||
]]>
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>releasesPolicy</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<defaultValue>never</defaultValue>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<p>
|
||||
The policy for releases, one of the following:
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#DISABLED disabled},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#DAILY daily},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#HOURLY hourly},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy#ONCE once}
|
||||
</p>
|
||||
|
||||
@see org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy
|
||||
]]>
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<name>policies</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<defaultValue>fail</defaultValue>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<p>
|
||||
The policy for dealing with checksums, one of the following:
|
||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#FAIL fail},
|
||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#FIX fix}, or
|
||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#IGNORE ignore}
|
||||
</p>
|
||||
|
||||
@see org.apache.maven.archiva.proxy.policy.ChecksumPolicy
|
||||
]]>
|
||||
</description>
|
||||
<type>Properties</type>
|
||||
<description>Policy configuration for the connector.</description>
|
||||
<association xml.mapStyle="inline">
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>properties</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>Properties</type>
|
||||
<description>Configuration for the connector.</description>
|
||||
<association xml.mapStyle="inline">
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0+</version>
|
||||
<code><![CDATA[
|
||||
/**
|
||||
* Obtain a specific policy from the underlying connector.
|
||||
*
|
||||
* @param policyId the policy id to fetch.
|
||||
* @param defaultValue the default value for the policy id.
|
||||
* @return the configured policy value (or default value if not found).
|
||||
*/
|
||||
public String getPolicy( String policyId, String defaultValue )
|
||||
{
|
||||
if ( this.getPolicies() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.getPolicies().getProperty( policyId, defaultValue );
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<superClass>AbstractRepositoryConnectorConfiguration</superClass>
|
||||
<name>RepositorySynchConnectorConfiguration</name>
|
||||
<name>ProxyConnectorConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<fields>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0+</version>
|
||||
<code><![CDATA[
|
||||
/**
|
||||
* The policy key {@link #getPolicies()} for snapshot handling.
|
||||
* See {@link org.apache.maven.archiva.policies.SnapshotsPolicy}
|
||||
* for details on potential values to this policy key.
|
||||
*/
|
||||
public static final String POLICY_SNAPSHOTS = "snapshots";
|
||||
|
||||
/**
|
||||
* The policy key {@link #getPolicies()} for releases handling.
|
||||
* See {@link org.apache.maven.archiva.policies.ReleasesPolicy}
|
||||
* for details on potential values to this policy key.
|
||||
*/
|
||||
public static final String POLICY_RELEASES = "releases";
|
||||
|
||||
/**
|
||||
* The policy key {@link #getPolicies()} for checksum handling.
|
||||
* See {@link org.apache.maven.archiva.policies.ChecksumPolicy}
|
||||
* for details on potential values to this policy key.
|
||||
*/
|
||||
public static final String POLICY_CHECKSUM = "checksum";
|
||||
|
||||
/**
|
||||
* The policy key {@link #getPolicies()} for cache-failures handling.
|
||||
* See {@link org.apache.maven.archiva.policies.CachedFailuresPolicy}
|
||||
* for details on potential values to this policy key.
|
||||
*/
|
||||
public static final String POLICY_CACHE_FAILURES = "cache-failures";
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<superClass>AbstractRepositoryConnectorConfiguration</superClass>
|
||||
<name>SyncConnectorConfiguration</name>
|
||||
<abstract>true</abstract>
|
||||
<version>1.0.0+</version>
|
||||
<fields>
|
||||
|
@ -394,16 +415,6 @@
|
|||
<description>The type of synchronization to use.</description>
|
||||
<defaultValue>rsync</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>properties</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>Properties</type>
|
||||
<description>Configuration for the repository synchronization.</description>
|
||||
<association xml.mapStyle="inline">
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
|
|
Loading…
Reference in New Issue