]> source.dussan.org Git - archiva.git/commitdiff
Overhaul of configuration schema
authorJoakim Erdfelt <joakime@apache.org>
Thu, 22 Mar 2007 19:33:28 +0000 (19:33 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 22 Mar 2007 19:33:28 +0000 (19:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@521414 13f79535-47bb-0310-9956-ffa450edef68

archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
archiva-configuration/src/main/mdo/configuration.mdo
archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml [new file with mode: 0644]
archiva-configuration/src/test/conf/repository-manager.xml
archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java

index f3c50fbc0791caf1c6faff28f9d0963e9b75f397..ab64a661d4f006e87644082bc5cf75b63b975e13 100644 (file)
@@ -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;
index fec53daf4aa5e9c673a97e22799ad65ccfc38fc7..070ed05399ae32f16af163f127a33701b3dbf3f4 100644 (file)
@@ -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 );
 
index 2893e289cf48566ff5bef7fefdd8b1ff8bd5cd49..75ba48c5323b6c9b5f13d8fddc5015fbe90008a9 100644 (file)
   <classes>\r
     <class rootElement="true" xml.tagName="configuration">\r
       <name>Configuration</name>\r
-      <version>1.0.0</version>\r
+      <version>1.0.0+</version>\r
       <fields>\r
         <field>\r
           <name>repositories</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <association>\r
             <type>RepositoryConfiguration</type>\r
-            <multiplicity>*</multiplicity>\r
-          </association>\r
-        </field>\r
-        <field>\r
-          <name>proxiedRepositories</name>\r
-          <version>1.0.0</version>\r
-          <association>\r
-            <type>ProxiedRepositoryConfiguration</type>\r
-            <multiplicity>*</multiplicity>\r
-          </association>\r
-        </field>\r
-        <field>\r
-          <name>syncedRepositories</name>\r
-          <version>1.0.0</version>\r
-          <association>\r
-            <type>SyncedRepositoryConfiguration</type>\r
-            <multiplicity>*</multiplicity>\r
-          </association>\r
-        </field>\r
-        <field>\r
-          <name>localRepository</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <description>\r
-            The location of the local repository.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>indexPath</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <description>\r
-            The location of the Lucene index to use for the repository. The default is the .index subdirectory of\r
-            the repository.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>minimalIndexPath</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <description>\r
-            The location of the reduced Lucene index to use for the repository. The default is the .small-index\r
-            subdirectory of the repository.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>dataRefreshCronExpression</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <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>\r
-          <defaultValue>0 0,30 * * * ?</defaultValue>\r
+            <multiplicity>*</multiplicity>
+          </association>
+          <description>The list of repositories that this archiva instance uses.</description>\r
+        </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.\r
+        <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>\r
-          <name>globalBlackListPatterns</name>\r
-          <version>1.0.0</version>\r
-          <description>Blacklisted patterns in the discovery process</description>\r
+          <name>networkProxies</name>\r
+          <version>1.0.0+</version>\r
           <association>\r
-            <type>String</type>\r
+            <type>ProxyConfiguration</type>
             <multiplicity>*</multiplicity>\r
           </association>\r
+          <description>
+               The list of network proxies to use for outgoing requests.
+          </description>\r
         </field>
-           -->\r
-        <field>\r
-          <name>proxy</name>\r
-          <version>1.0.0</version>\r
-          <association>\r
-            <type>Proxy</type>\r
-          </association>\r
-          <description>The network proxy to use for outgoing requests.</description>\r
+        <field>
+          <name>fileProcessors</name>
+          <version>1.0.0+</version>
+          <association>
+            <type>FileProcessor</type>
+            <multiplicity>*</multiplicity>
+          </association>
+          <description>
+            The file processors setup.
+          </description>
         </field>\r
       </fields>\r
-      <codeSegments>\r
-        <codeSegment>\r
-          <version>1.0.0</version>\r
-          <code><![CDATA[\r
-    public Configuration()\r
-    {\r
-        localRepository = new java.io.File( System.getProperty( "user.home" ), ".m2/repository" ).getAbsolutePath();\r
-    }\r
-\r
-    public boolean isValid()\r
-    {\r
-        boolean valid = true;\r
-\r
-        if ( indexPath == null )\r
-        {\r
-            valid = false;\r
-        }\r
-        else if ( getRepositories().isEmpty() )\r
-        {\r
-            valid = false;\r
-        }\r
-        return valid;\r
-    }\r
-\r
-    /**\r
-     * Perform any Upgrades and Adjustments needed to bring configuration up to the\r
-     * current configuration format.\r
-     */\r
-    public void sanitize()\r
-    {\r
-        for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
-        {\r
-            RepositoryConfiguration repo = (RepositoryConfiguration) i.next();\r
-\r
-            // Ensure that the repo.urlName is set.\r
-            if ( org.codehaus.plexus.util.StringUtils.isEmpty( repo.getUrlName() ) )\r
-            {\r
-                repo.setUrlName( repo.getId() );\r
-            }\r
-        }\r
-    }\r
-\r
-    public RepositoryConfiguration getRepositoryByUrlName( String urlName )\r
-    {\r
-        for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
-        {\r
-            RepositoryConfiguration repository = (RepositoryConfiguration) i.next();\r
-            if ( urlName != null ? urlName.equals( repository.getUrlName() ) : repository.getUrlName() == null )\r
-            {\r
-                return repository;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
+    </class>
+    
+    <!-- 
+       ____                      _ _
+      |  _ \ ___ _ __   ___  ___(_) |_ ___  _ __ _   _
+      | |_) / _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | |
+      |  _ <  __/ |_) | (_) \__ \ | || (_) | |  | |_| |
+      |_| \_\___| .__/ \___/|___/_|\__\___/|_|   \__, |
+                |_|                              |___/
+    
+      -->
     \r
-    public RepositoryConfiguration getRepositoryById( String id )\r
-    {\r
-        for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
-        {\r
-            RepositoryConfiguration repository = (RepositoryConfiguration) i.next();\r
-            if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )\r
-            {\r
-                return repository;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public SyncedRepositoryConfiguration getSyncedRepositoryById( String id )\r
-    {\r
-        for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )\r
-        {\r
-            SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();\r
-            if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )\r
-            {\r
-                return repository;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public ProxiedRepositoryConfiguration getProxiedRepositoryById( String id )\r
-    {\r
-        for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )\r
-        {\r
-            ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();\r
-            if ( id != null ? id.equals( repository.getId() ) : repository.getId() == null )\r
-            {\r
-                return repository;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    private java.util.Map repositoriesMap;\r
-\r
-    public java.util.Map getRepositoriesMap()\r
-    {\r
-        if ( repositoriesMap == null )\r
-        {\r
-            repositoriesMap = new java.util.HashMap();\r
-            for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )\r
-            {\r
-                RepositoryConfiguration repository = (RepositoryConfiguration) i.next();\r
-                repositoriesMap.put( repository.getId(), repository );\r
-            }\r
-        }\r
-        return repositoriesMap;\r
-    }\r
-\r
-    private java.util.Map proxiedRepositoriesMap;\r
-\r
-    public java.util.Map getProxiedRepositoriesMap()\r
-    {\r
-        if ( proxiedRepositoriesMap == null )\r
-        {\r
-            proxiedRepositoriesMap = new java.util.HashMap();\r
-            for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )\r
-            {\r
-                ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();\r
-                proxiedRepositoriesMap.put( repository.getId(), repository );\r
-            }\r
-        }\r
-        return proxiedRepositoriesMap;\r
-    }\r
-\r
-    private java.util.Map syncedRepositoriesMap;\r
-\r
-    public java.util.Map getSyncedRepositoriesMap()\r
-    {\r
-        if ( syncedRepositoriesMap == null )\r
-        {\r
-            syncedRepositoriesMap = new java.util.HashMap();\r
-            for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )\r
-            {\r
-                SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();\r
-                syncedRepositoriesMap.put( repository.getId(), repository );\r
-            }\r
-        }\r
-        return syncedRepositoriesMap;\r
-    }\r
-          ]]></code>\r
-        </codeSegment>\r
-      </codeSegments>\r
-    </class>\r
-    <class>\r
-      <name>AbstractRepositoryConfiguration</name>\r
-      <abstract>true</abstract>\r
-      <version>1.0.0</version>\r
-      <fields>\r
-        <field>\r
-          <name>id</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The repository identifier.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>name</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The descriptive name of the repository.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>layout</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The layout of the repository. Valid values are "default" and "legacy".\r
-          </description>\r
-          <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->\r
-          <defaultValue>default</defaultValue>\r
-        </field>\r
-      </fields>\r
-      <codeSegments>\r
-        <codeSegment>\r
-          <version>1.0.0</version>\r
-          <code><![CDATA[\r
-    public String toString()\r
-    {\r
-        return name + " (" + id + ")";\r
-    }\r
-          ]]></code>\r
-        </codeSegment>\r
-      </codeSegments>\r
-    </class>\r
     <class>\r
-      <superClass>AbstractRepositoryConfiguration</superClass>\r
       <name>RepositoryConfiguration</name>\r
-      <version>1.0.0</version>\r
+      <version>1.0.0+</version>\r
       <fields>\r
+        <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>\r
-          <name>urlName</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The URL name for this repository.\r
-            Used to create the WebDAV URL for the repository such like - http://hostname.com/repository/${urlName}/\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>directory</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The location of the repository to monitor.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>includeSnapshots</name>\r
-          <version>1.0.0</version>\r
+          <name>snapshots</name>\r
+          <version>1.0.0+</version>\r
           <type>boolean</type>\r
-          <description>Whether to include snapshot versions in the discovery process</description>\r
+          <description>True if this repository contains snapshot versioned artifacts.</description>\r
           <defaultValue>false</defaultValue>\r
         </field>\r
         <field>\r
           <name>indexed</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <type>boolean</type>\r
-          <description>Whether to index the artifacts in this repository.</description>\r
+          <description>True if this repository should be indexed.</description>\r
           <defaultValue>true</defaultValue>\r
-        </field>\r
-        <field>\r
-          <name>blackListPatterns</name>\r
-          <version>1.0.0</version>\r
-          <description>Blacklisted patterns in the discovery process</description>\r
-          <association>\r
-            <type>String</type>\r
-            <multiplicity>*</multiplicity>\r
-          </association>\r
-        </field>\r
+        </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>\r
-    </class>\r
+    </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>
+    \r
     <class>\r
-      <superClass>AbstractRepositoryConfiguration</superClass>\r
-      <name>ProxiedRepositoryConfiguration</name>\r
-      <version>1.0.0</version>\r
-      <fields>\r
-        <field>\r
-          <name>url</name>\r
-          <version>1.0.0</version>\r
-          <type>String</type>\r
-          <required>true</required>\r
-          <description>\r
-            The URL of the remote repository to proxy.\r
-          </description>\r
-        </field>\r
-        <!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->\r
-        <field>\r
-          <name>managedRepository</name>\r
-          <version>1.0.0</version>\r
-          <required>true</required>\r
-          <type>String</type>\r
-          <description>\r
-            The ID of the managed repository to use as the local storage for proxied artifacts.\r
-          </description>\r
-        </field>\r
+      <superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
+      <name>RepositoryProxyConnectorConfiguration</name>\r
+      <version>1.0.0+</version>\r
+      <fields>
         <field>\r
           <name>snapshotsPolicy</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <type>String</type>\r
           <defaultValue>disabled</defaultValue>\r
           <description>\r
-            The policy for snapshots: one of disabled, daily, hourly, interval, never\r
-            (allow snapshots, but never update once retrieved).\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>snapshotsInterval</name>\r
-          <version>1.0.0</version>\r
-          <type>int</type>\r
-          <description>\r
-            The interval in minutes before updating snapshots if the policy is set to 'interval'.\r
+            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.\r
           </description>\r
         </field>\r
         <field>\r
           <name>releasesPolicy</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <type>String</type>\r
-          <defaultValue>daily</defaultValue>\r
+          <defaultValue>never</defaultValue>\r
           <description>\r
-            The policy for releases: one of disabled, daily, hourly, interval, never\r
-            (allow releases, but never update once retrieved).\r
+            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>\r
         </field>\r
         <field>\r
-          <name>releasesInterval</name>\r
-          <version>1.0.0</version>\r
-          <type>int</type>\r
-          <description>\r
-            The interval in minutes before updating releases if the policy is set to 'interval'.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>useNetworkProxy</name>\r
-          <version>1.0.0</version>\r
-          <type>boolean</type>\r
-          <defaultValue>false</defaultValue>\r
-          <description>\r
-            Whether to use the network proxy, if one is configured for the protocol of this repository.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>cacheFailures</name>\r
-          <version>1.0.0</version>\r
-          <type>boolean</type>\r
-          <defaultValue>false</defaultValue>\r
-          <description>\r
-            Whether to cache failures to avoid re-attempting them over the network. The cache will last for the duration\r
-            of the intervals specified above depending on whether it a release or snapshot.\r
-          </description>\r
-        </field>\r
-        <field>\r
-          <name>hardFail</name>\r
-          <version>1.0.0</version>\r
-          <type>boolean</type>\r
-          <defaultValue>false</defaultValue>\r
-          <description>\r
-            Whether to cause the entire request to fail if attempts to retrieve from this proxy fail.\r
+          <name>failurePolicy</name>\r
+          <version>1.0.0+</version>\r
+          <type>String</type>\r
+          <defaultValue>not-found</defaultValue>\r
+          <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>\r
-        </field>\r
-      </fields>\r
-    </class>\r
+        </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>\r
+    </class>
+    \r
     <class>\r
-      <superClass>AbstractRepositoryConfiguration</superClass>\r
-      <name>SyncedRepositoryConfiguration</name>\r
+      <superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
+      <name>RepositorySynchConnectorConfiguration</name>\r
       <abstract>true</abstract>\r
-      <version>1.0.0</version>\r
+      <version>1.0.0+</version>\r
       <fields>\r
-        <!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->\r
-        <field>\r
-          <name>managedRepository</name>\r
-          <version>1.0.0</version>\r
-          <required>true</required>\r
-          <type>String</type>\r
-          <description>\r
-            The ID of the managed repository to use as the local storage for proxied artifacts.\r
-          </description>\r
-        </field>\r
         <field>\r
           <name>cronExpression</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <type>String</type>\r
           <description>When to run the sync mechanism. Default is every hour on the hour.</description>\r
           <defaultValue>0 0 * * * ?</defaultValue>\r
         </field>\r
         <field>\r
           <name>method</name>\r
-          <version>1.0.0</version>\r
+          <version>1.0.0+</version>\r
           <type>String</type>\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
+          <version>1.0.0+</version>\r
           <type>Properties</type>\r
           <description>Configuration for the repository synchronization.</description>\r
           <association xml.mapStyle="inline">\r
           </association>\r
         </field>\r
       </fields>\r
-    </class>\r
+    </class>
+    
+    <!-- 
+       ____                _
+      |  _ \ _ __ _____  _(_) ___  ___
+      | |_) | '__/ _ \ \/ / |/ _ \/ __|
+      |  __/| | | (_) >  <| |  __/\__ \
+      |_|   |_|  \___/_/\_\_|\___||___/
+    
+      -->
+    \r
     <class>\r
-      <name>Proxy</name>\r
-      <version>1.0.0</version>\r
-      <fields>\r
-        <field>\r
-          <name>protocol</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[The proxy protocol.]]></description>\r
-          <type>String</type>\r
-          <defaultValue>http</defaultValue>\r
-        </field>\r
+      <name>ProxyConfiguration</name>\r
+      <version>1.0.0+</version>\r
+      <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>\r
+        <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>\r
           <name>username</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[The proxy user.]]></description>\r
+          <version>1.0.0+</version>\r
+          <description>
+               The proxy user.
+          </description>\r
           <type>String</type>\r
         </field>\r
         <field>\r
           <name>password</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[The proxy password.]]></description>\r
-          <type>String</type>\r
-        </field>\r
-        <field>\r
-          <name>port</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[The proxy port.]]></description>\r
-          <type>int</type>\r
-          <defaultValue>8080</defaultValue>\r
-        </field>\r
-        <field>\r
-          <name>host</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[The proxy host.]]></description>\r
-          <type>String</type>\r
-          <required>true</required>\r
-        </field>\r
-        <field>\r
-          <name>nonProxyHosts</name>\r
-          <version>1.0.0</version>\r
-          <description><![CDATA[\r
-                The list of non-proxied hosts (delimited by |).\r
-          ]]></description>\r
+          <version>1.0.0+</version>\r
+          <description>
+               The proxy password.
+          </description>\r
           <type>String</type>\r
-        </field>\r
+        </field>
       </fields>\r
-    </class>\r
+    </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>
+    \r
   </classes>\r
 </model>\r
 \r
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 (file)
index 0000000..4c48beb
--- /dev/null
@@ -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>
index 4008e250371fcc4d5021acbb6911d12e2157f9ad..44e7fc155349d3fa42f242675006804b7de8f926 100644 (file)
 <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>
index 4c21b15df4ba31ccb6bf71e4fce6a20b6fb8e660..8f4243c27a6ae66f53aec9c80a969dae16fa6f3f 100644 (file)
@@ -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() );
     }
 }
index e56bf2aa137690f6bba092f8c44b891f425a179d..0911260878117b1f3c9c8fbc89965222abefac19 100644 (file)
@@ -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();