*/
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;
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 );
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 );
}
}
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 );
<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>
<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>
The list of whitelisted patterns for this connector.
</description>
</field>
+ <field>
+ <name>policies</name>
+ <version>1.0.0+</version>
+ <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>
\r
<class>\r
<superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
- <name>RepositoryProxyConnectorConfiguration</name>\r
+ <name>ProxyConnectorConfiguration</name>\r
<version>1.0.0+</version>\r
<fields>
- <field>\r
- <name>snapshotsPolicy</name>\r
- <version>1.0.0+</version>\r
- <type>String</type>\r
- <defaultValue>disabled</defaultValue>\r
- <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>
+ </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";
- @see org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy
- ]]>
- </description>
- </field>\r
- <field>\r
- <name>releasesPolicy</name>\r
- <version>1.0.0+</version>\r
- <type>String</type>\r
- <defaultValue>never</defaultValue>\r
- <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>\r
+ /**
+ * 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";
- @see org.apache.maven.archiva.proxy.policy.ArtifactUpdatePolicy
- ]]>
- </description>\r
- </field>\r
- <field>
- <name>checksumPolicy</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>
- </field>
- </fields>
+ /**
+ * 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>
\r
<class>\r
<superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
- <name>RepositorySynchConnectorConfiguration</name>\r
+ <name>SyncConnectorConfiguration</name>\r
<abstract>true</abstract>\r
<version>1.0.0+</version>\r
<fields>\r
<description>The type of synchronization to use.</description>\r
<defaultValue>rsync</defaultValue>\r
</field>\r
- <field>\r
- <name>properties</name>\r
- <version>1.0.0+</version>\r
- <type>Properties</type>\r
- <description>Configuration for the repository synchronization.</description>\r
- <association xml.mapStyle="inline">\r
- <type>String</type>\r
- <multiplicity>*</multiplicity>\r
- </association>\r
- </field>\r
</fields>\r
</class>