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>
|
<artifactId>archiva-configuration</artifactId>
|
||||||
<name>Archiva Base :: Configuration</name>
|
<name>Archiva Base :: Configuration</name>
|
||||||
<dependencies>
|
<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>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-component-api</artifactId>
|
<artifactId>plexus-component-api</artifactId>
|
||||||
|
|
|
@ -20,11 +20,12 @@ package org.apache.maven.archiva.configuration;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -41,13 +42,14 @@ public class MavenProxyPropertyLoader
|
||||||
|
|
||||||
private static final String REPO_LIST = "repo.list";
|
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
|
// set up the managed repository
|
||||||
String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE );
|
String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE );
|
||||||
|
|
||||||
RepositoryConfiguration config = new RepositoryConfiguration();
|
RepositoryConfiguration config = new RepositoryConfiguration();
|
||||||
config.setUrl( toURL( localCachePath ) );
|
config.setUrl( PathUtil.toUrl( localCachePath ) );
|
||||||
config.setName( "Imported Maven-Proxy Cache" );
|
config.setName( "Imported Maven-Proxy Cache" );
|
||||||
config.setId( "maven-proxy" );
|
config.setId( "maven-proxy" );
|
||||||
configuration.addRepository( config );
|
configuration.addRepository( config );
|
||||||
|
@ -97,31 +99,20 @@ public class MavenProxyPropertyLoader
|
||||||
repository.setIndexed( false );
|
repository.setIndexed( false );
|
||||||
repository.setReleases( true );
|
repository.setReleases( true );
|
||||||
repository.setSnapshots( false );
|
repository.setSnapshots( false );
|
||||||
|
|
||||||
configuration.addRepository( repository );
|
configuration.addRepository( repository );
|
||||||
|
|
||||||
RepositoryProxyConnectorConfiguration proxyConnector = new RepositoryProxyConnectorConfiguration();
|
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
|
||||||
proxyConnector.setSourceRepoId( "maven-proxy" );
|
proxyConnector.setSourceRepoId( "maven-proxy" );
|
||||||
proxyConnector.setTargetRepoId( key );
|
proxyConnector.setTargetRepoId( key );
|
||||||
proxyConnector.setProxyId( proxyKey );
|
proxyConnector.setProxyId( proxyKey );
|
||||||
// TODO: convert cachePeriod to closest "daily" or "hourly"
|
// TODO: convert cachePeriod to closest "daily" or "hourly"
|
||||||
proxyConnector.setSnapshotsPolicy( "daily" );
|
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS,
|
||||||
proxyConnector.setReleasesPolicy( "never" );
|
SnapshotsPolicy.DAILY );
|
||||||
|
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES,
|
||||||
configuration.addProxyConnector( proxyConnector );
|
ReleasesPolicy.IGNORED );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toURL( String path )
|
configuration.addProxyConnector( proxyConnector );
|
||||||
{
|
|
||||||
File file = new File( path );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return file.toURL().toExternalForm();
|
|
||||||
}
|
|
||||||
catch ( MalformedURLException e )
|
|
||||||
{
|
|
||||||
return "file://" + StringUtils.replaceChars( file.getAbsolutePath(), '\\', '/' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,14 +133,16 @@ public class MavenProxyPropertyLoader
|
||||||
return result;
|
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();
|
Properties props = new Properties();
|
||||||
props.load( is );
|
props.load( is );
|
||||||
load( props, configuration );
|
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 );
|
String value = props.getProperty( key );
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<name>proxyConnectors</name>
|
<name>proxyConnectors</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
<association>
|
<association>
|
||||||
<type>RepositoryProxyConnectorConfiguration</type>
|
<type>ProxyConnectorConfiguration</type>
|
||||||
<multiplicity>*</multiplicity>
|
<multiplicity>*</multiplicity>
|
||||||
</association>
|
</association>
|
||||||
<description>The list of proxy connectors for this archiva instance.</description>
|
<description>The list of proxy connectors for this archiva instance.</description>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<name>syncConnectors</name>
|
<name>syncConnectors</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
<association>
|
<association>
|
||||||
<type>RepositorySyncConnectorConfiguration</type>
|
<type>SyncConnectorConfiguration</type>
|
||||||
<multiplicity>*</multiplicity>
|
<multiplicity>*</multiplicity>
|
||||||
</association>
|
</association>
|
||||||
<description>The list of sync connectors for this archiva instance.</description>
|
<description>The list of sync connectors for this archiva instance.</description>
|
||||||
|
@ -307,76 +307,97 @@
|
||||||
The list of whitelisted patterns for this connector.
|
The list of whitelisted patterns for this connector.
|
||||||
</description>
|
</description>
|
||||||
</field>
|
</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>
|
<field>
|
||||||
<name>checksumPolicy</name>
|
<name>policies</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
<type>String</type>
|
<type>Properties</type>
|
||||||
<defaultValue>fail</defaultValue>
|
<description>Policy configuration for the connector.</description>
|
||||||
<description>
|
<association xml.mapStyle="inline">
|
||||||
<![CDATA[
|
<type>String</type>
|
||||||
<p>
|
<multiplicity>*</multiplicity>
|
||||||
The policy for dealing with checksums, one of the following:
|
</association>
|
||||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#FAIL fail},
|
</field>
|
||||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#FIX fix}, or
|
<field>
|
||||||
{@link org.apache.maven.archiva.proxy.policy.ChecksumPolicy#IGNORE ignore}
|
<name>properties</name>
|
||||||
</p>
|
<version>1.0.0+</version>
|
||||||
|
<type>Properties</type>
|
||||||
@see org.apache.maven.archiva.proxy.policy.ChecksumPolicy
|
<description>Configuration for the connector.</description>
|
||||||
]]>
|
<association xml.mapStyle="inline">
|
||||||
</description>
|
<type>String</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
</field>
|
</field>
|
||||||
</fields>
|
</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>
|
||||||
|
|
||||||
<class>
|
<class>
|
||||||
<superClass>AbstractRepositoryConnectorConfiguration</superClass>
|
<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>
|
<abstract>true</abstract>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -394,16 +415,6 @@
|
||||||
<description>The type of synchronization to use.</description>
|
<description>The type of synchronization to use.</description>
|
||||||
<defaultValue>rsync</defaultValue>
|
<defaultValue>rsync</defaultValue>
|
||||||
</field>
|
</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>
|
</fields>
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue