();
+ int len = version.length();
+ int i = 0;
+ int start = 0;
+ int mode = modeOther;
+
+ while ( i < len )
+ {
+ char c = version.charAt( i );
+
+ if ( Character.isDigit( c ) )
+ {
+ if ( mode != modeDigit )
+ {
+ if ( mode != modeOther )
+ {
+ parts.add( version.substring( start, i ) );
+ }
+ mode = modeDigit;
+ start = i;
+ }
+ }
+ else if ( Character.isLetter( c ) )
+ {
+ if ( mode != modeText )
+ {
+ if ( mode != modeOther )
+ {
+ parts.add( version.substring( start, i ) );
+ }
+ mode = modeText;
+ start = i;
+ }
+ }
+ else
+ {
+ // Other.
+ if ( mode != modeOther )
+ {
+ parts.add( version.substring( start, i ) );
+ mode = modeOther;
+ }
+ }
+
+ i++;
+ }
+
+ // Add remainder
+ if ( mode != modeOther )
+ {
+ parts.add( version.substring( start, i ) );
+ }
+
+ return parts.toArray( new String[parts.size()] );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java
new file mode 100644
index 000000000..2e3831d4a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java
@@ -0,0 +1,204 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Version utility methods.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class VersionUtil
+{
+ /**
+ * These are the version patterns found in the filenames of the various artifact's versions IDs.
+ * These patterns are all tackling lowercase version IDs.
+ */
+ private static final String versionPatterns[] = new String[] {
+ "([0-9][_.0-9a-z]*)",
+ "(snapshot)",
+ "(g?[_.0-9ab]*(pre|rc|g|m)[_.0-9]*)",
+ "(dev[_.0-9]*)",
+ "(alpha[_.0-9]*)",
+ "(beta[_.0-9]*)",
+ "(rc[_.0-9]*)",
+// "(test[_.0-9]*)", -- omitted for MRM-681, can be reinstated as part of MRM-712
+ "(debug[_.0-9]*)",
+ "(unofficial[_.0-9]*)",
+ "(current)",
+ "(latest)",
+ "(fcs)",
+ "(release[_.0-9]*)",
+ "(nightly)",
+ "(final)",
+ "(incubating)",
+ "(incubator)",
+ "([ab][_.0-9]+)" };
+
+ public static final String SNAPSHOT = "SNAPSHOT";
+
+ public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" );
+
+ public static final Pattern TIMESTAMP_PATTERN = Pattern.compile( "^([0-9]{8})\\.([0-9]{6})$" );
+
+ public static final Pattern GENERIC_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-" + SNAPSHOT );
+
+ private static final Pattern VERSION_MEGA_PATTERN = Pattern.compile( StringUtils.join( versionPatterns, '|' ), Pattern.CASE_INSENSITIVE );
+
+ /**
+ *
+ * Tests if the unknown string contains elements that identify it as a version string (or not).
+ *
+ *
+ *
+ * The algorithm tests each part of the string that is delimited by a '-' (dash) character.
+ * If 75% or more of the sections are identified as 'version' strings, the result is
+ * determined to be of a high probability to be version identifier string.
+ *
+ *
+ * @param unknown the unknown string to test.
+ * @return true if the unknown string is likely a version string.
+ */
+ public static boolean isVersion( String unknown )
+ {
+ String versionParts[] = StringUtils.split( unknown, '-' );
+
+ Matcher mat;
+
+ int countValidParts = 0;
+
+ for ( int i = 0; i < versionParts.length; i++ )
+ {
+ String part = versionParts[i];
+ mat = VERSION_MEGA_PATTERN.matcher( part );
+
+ if ( mat.matches() )
+ {
+ countValidParts++;
+ }
+ }
+
+ /* Calculate version probability as true if 3/4's of the input string has pieces of
+ * of known version identifier strings.
+ */
+ int threshold = (int) Math.floor( Math.max( (double) 1.0, (double) ( versionParts.length * 0.75 ) ) );
+
+ return ( countValidParts >= threshold );
+ }
+
+ /**
+ *
+ * Tests if the identifier is a known simple version keyword.
+ *
+ *
+ *
+ * This method is different from {@link #isVersion(String)} in that it tests the whole input string in
+ * one go as a simple identifier. (eg "alpha", "1.0", "beta", "debug", "latest", "rc#", etc...)
+ *
+ *
+ * @param identifier the identifier to test.
+ * @return true if the unknown string is likely a version string.
+ */
+ public static boolean isSimpleVersionKeyword( String identifier )
+ {
+ Matcher mat = VERSION_MEGA_PATTERN.matcher( identifier );
+
+ return mat.matches();
+ }
+
+ public static boolean isSnapshot( String version )
+ {
+ Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version );
+ if ( m.matches() )
+ {
+ return true;
+ }
+ else
+ {
+ return version.endsWith( SNAPSHOT );
+ }
+ }
+
+ public static String getBaseVersion( String version )
+ {
+ Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version );
+ if ( m.matches() )
+ {
+ return m.group( 1 ) + "-" + SNAPSHOT;
+ }
+ else
+ {
+ return version;
+ }
+ }
+
+ /**
+ *
+ * Get the release version of the snapshot version.
+ *
+ *
+ *
+ * If snapshot version is 1.0-SNAPSHOT, then release version would be 1.0
+ * And if snapshot version is 1.0-20070113.163208-1.jar, then release version would still be 1.0
+ *
+ *
+ * @param snapshotVersion
+ * @return
+ */
+ public static String getReleaseVersion( String snapshotVersion )
+ {
+ Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( snapshotVersion );
+
+ if( isGenericSnapshot( snapshotVersion ) )
+ {
+ m = GENERIC_SNAPSHOT_PATTERN.matcher( snapshotVersion );
+ }
+
+ if ( m.matches() )
+ {
+ return m.group( 1 );
+ }
+ else
+ {
+ return snapshotVersion;
+ }
+ }
+
+ public static boolean isUniqueSnapshot( String version )
+ {
+ Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version );
+ if( m.matches() )
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean isGenericSnapshot( String version )
+ {
+ return version.endsWith( SNAPSHOT );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java
new file mode 100644
index 000000000..4de78842b
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java
@@ -0,0 +1,132 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+
+/**
+ * BaseFileTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class BaseFileTest
+ extends TestCase
+{
+ public void testFileString()
+ {
+ File repoDir = new File( "/home/user/foo/repository" );
+ String pathFile = "path/to/resource.xml";
+ BaseFile file = new BaseFile( repoDir, pathFile );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testFileFile()
+ {
+ File repoDir = new File( "/home/user/foo/repository" );
+ File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
+ BaseFile file = new BaseFile( repoDir, pathFile );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testStringFile()
+ {
+ String repoDir = "/home/user/foo/repository";
+ File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
+ BaseFile file = new BaseFile( repoDir, pathFile );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testFileThenSetBaseString()
+ {
+ String repoDir = "/home/user/foo/repository";
+ File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
+ BaseFile file = new BaseFile( pathFile );
+ file.setBaseDir( repoDir );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testFileThenSetBaseFile()
+ {
+ File repoDir = new File( "/home/user/foo/repository" );
+ File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
+ BaseFile file = new BaseFile( pathFile );
+ file.setBaseDir( repoDir );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testStringThenSetBaseString()
+ {
+ String repoDir = "/home/user/foo/repository";
+ String pathFile = "/home/user/foo/repository/path/to/resource.xml";
+ BaseFile file = new BaseFile( pathFile );
+ file.setBaseDir( repoDir );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ public void testStringThenSetBaseFile()
+ {
+ File repoDir = new File( "/home/user/foo/repository" );
+ String pathFile = "/home/user/foo/repository/path/to/resource.xml";
+ BaseFile file = new BaseFile( pathFile );
+ file.setBaseDir( repoDir );
+
+ assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
+ assertRelativePath( "path/to/resource.xml", file );
+ assertBasedir( "/home/user/foo/repository", file );
+ }
+
+ private void assertAbsolutePath( String expectedPath, BaseFile actualFile )
+ {
+ assertEquals( new File( expectedPath ).getAbsolutePath(), actualFile.getAbsolutePath() );
+ }
+
+ private void assertRelativePath( String expectedPath, BaseFile actualFile )
+ {
+ assertEquals( expectedPath, StringUtils.replace( actualFile.getRelativePath(), "\\", "/" ) );
+ }
+
+ private void assertBasedir( String expectedPath, BaseFile actualFile )
+ {
+ assertEquals( new File( expectedPath ), actualFile.getBaseDir() );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java
new file mode 100644
index 000000000..b080227fe
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java
@@ -0,0 +1,69 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+/**
+ * DateUtilTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class DateUtilTest extends TestCase
+{
+ private void assertDuration( String expectedDuration, String startTimestamp, String endTimestamp )
+ throws ParseException
+ {
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss SSS" );
+ Date startDate = sdf.parse( startTimestamp );
+ Date endDate = sdf.parse( endTimestamp );
+
+// System.out.println( "Date: " + endTimestamp + " - " + startTimestamp + " = "
+// + ( endDate.getTime() - startDate.getTime() ) + " ms" );
+
+ assertEquals( expectedDuration, DateUtil.getDuration( startDate, endDate ) );
+ }
+
+ public void testGetDurationDifference() throws ParseException
+ {
+ assertDuration( "2 Seconds", "2006-08-22 13:00:02 0000",
+ "2006-08-22 13:00:04 0000" );
+
+ assertDuration( "12 Minutes 12 Seconds 234 Milliseconds", "2006-08-22 13:12:02 0000",
+ "2006-08-22 13:24:14 0234" );
+
+ assertDuration( "12 Minutes 501 Milliseconds", "2006-08-22 13:12:01 0500",
+ "2006-08-22 13:24:02 0001" );
+ }
+
+ public void testGetDurationDirect() throws ParseException
+ {
+ assertEquals( "2 Seconds", DateUtil.getDuration( 2000 ) );
+
+ assertEquals( "12 Minutes 12 Seconds 234 Milliseconds", DateUtil.getDuration( 732234 ) );
+
+ assertEquals( "12 Minutes 501 Milliseconds", DateUtil.getDuration( 720501 ) );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java
new file mode 100644
index 000000000..a318e57f4
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java
@@ -0,0 +1,94 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+/**
+ * PathUtilTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class PathUtilTest
+ extends TestCase
+{
+ public void testToRelativeWithoutSlash()
+ {
+ assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository",
+ "/home/user/foo/repository/path/to/resource.xml" ) );
+ }
+
+ public void testToRelativeWithSlash()
+ {
+ assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository/",
+ "/home/user/foo/repository/path/to/resource.xml" ) );
+ }
+
+ public void testToUrlRelativePath()
+ {
+ File workingDir = new File( "." );
+
+ String workingDirname = StringUtils.replaceChars( workingDir.getAbsolutePath(), '\\', '/' );
+
+ // Some JVM's retain the "." at the end of the path. Drop it.
+ if ( workingDirname.endsWith( "/." ) )
+ {
+ workingDirname = workingDirname.substring( 0, workingDirname.length() - 2 );
+ }
+
+ if ( !workingDirname.startsWith( "/" ) )
+ {
+ workingDirname = "/" + workingDirname;
+ }
+
+ String path = "path/to/resource.xml";
+ String expectedPath = "file:" + workingDirname + "/" + path;
+
+ assertEquals( expectedPath, PathUtil.toUrl( path ) );
+ }
+
+ public void testToUrlUsingFileUrl()
+ {
+ File workingDir = new File( "." );
+
+ String workingDirname = StringUtils.replaceChars( workingDir.getAbsolutePath(), '\\', '/' );
+
+ // Some JVM's retain the "." at the end of the path. Drop it.
+ if ( workingDirname.endsWith( "/." ) )
+ {
+ workingDirname = workingDirname.substring( 0, workingDirname.length() - 2 );
+ }
+
+ if ( !workingDirname.startsWith( "/" ) )
+ {
+ workingDirname = "/" + workingDirname;
+ }
+
+ String path = "path/to/resource.xml";
+ String expectedPath = "file:" + workingDirname + "/" + path;
+
+ assertEquals( expectedPath, PathUtil.toUrl( expectedPath ) );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/ResourceUtils.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/ResourceUtils.java
new file mode 100644
index 000000000..db2a0dc27
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/ResourceUtils.java
@@ -0,0 +1,90 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * ResourceUtils
+ */
+public class ResourceUtils
+{
+ /**
+ * Lookup resource at the given path relative to the root of the classpath and if it exists return a file object
+ * that can be used to access it.
+ *
+ * At test time the contents of both the src/resources and test/resources dirs are available at the root of the
+ * classpath.
+ *
+ * To retrieve the file src/test/resources/sometest/test.properties use getResource("/sometest/test.properties").
+ *
+ * @param resourcePath the path to the resource relative to the root of the classpath
+ * @return File a file object pointing to the resource on the classpath or null if the resource cannot be found
+ */
+ public static File getResource( String resourcePath )
+ throws IOException
+ {
+ return getResource( resourcePath, null );
+ }
+
+ /**
+ * Lookup resource at the given path relative to the root of the classpath and if it exists return a file object
+ * that can be used to access it.
+ *
+ * At test time the contents of both the src/resources and test/resources dirs are available at the root of the
+ * classpath.
+ *
+ * To retrieve the file src/test/resources/sometest/test.properties use getResource("/sometest/test.properties").
+ *
+ * @param resourcePath the path to the resource relative to the root of the classpath
+ * @param classloader the classloader who's classpath should be searched for the resource
+ * @return File a file object pointing to the resource on the classpath or null if the resource cannot be found
+ */
+ public static File getResource( String resourcePath, ClassLoader classloader )
+ throws IOException
+ {
+ File testResource = null;
+
+ if ( StringUtils.isNotBlank( resourcePath ) )
+ {
+ // make sure the retrieval is relative to the root of the classpath
+ resourcePath = resourcePath.startsWith( "/" ) ? resourcePath : "/" + resourcePath;
+
+ URL resourceUrl = getResourceUrl( resourcePath, classloader );
+ if ( resourceUrl == null )
+ {
+ throw new IOException( "Could not find test resource at path '" + resourcePath + "'" );
+ }
+ testResource = new File( resourceUrl.getFile() );
+ }
+
+ return testResource;
+ }
+
+ private static URL getResourceUrl( String resourcePath, ClassLoader classloader )
+ {
+ return classloader != null ? classloader.getResource( resourcePath )
+ : ResourceUtils.class.getResource( resourcePath );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/VersionComparatorTest.java b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/VersionComparatorTest.java
new file mode 100644
index 000000000..4bfef29fb
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/VersionComparatorTest.java
@@ -0,0 +1,131 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * VersionComparatorTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class VersionComparatorTest
+ extends TestCase
+{
+ public void testComparator()
+ {
+ /* Sort order is oldest to newest */
+
+ assertSort( new String[] { "1.0", "3.0", "2.0" }, new String[] { "1.0", "2.0", "3.0" } );
+ assertSort( new String[] { "1.5", "1.2", "1.0" }, new String[] { "1.0", "1.2", "1.5" } );
+
+ assertSort( new String[] { "1.5-SNAPSHOT", "1.2", "1.20" }, new String[] { "1.2", "1.5-SNAPSHOT", "1.20" } );
+
+ assertSort( new String[] { "1.1", "1.0-SNAPSHOT", "1.1-m6", "1.1-rc1" }, new String[] {
+ "1.0-SNAPSHOT",
+ "1.1-rc1",
+ "1.1-m6",
+ "1.1" } );
+
+ assertSort( new String[] { "1.1-m6", "1.0-SNAPSHOT", "1.1-rc1", "1.1" }, new String[] {
+ "1.0-SNAPSHOT",
+ "1.1-rc1",
+ "1.1-m6",
+ "1.1" } );
+
+ assertSort( new String[] { "2.0.5", "2.0.4-SNAPSHOT", "2.0", "2.0-rc1" }, new String[] {
+ "2.0-rc1",
+ "2.0",
+ "2.0.4-SNAPSHOT",
+ "2.0.5" } );
+
+ assertSort( new String[] { "1.0-alpha-1", "1.0-alpha-22", "1.0-alpha-10", "1.0-alpha-9" }, new String[] {
+ "1.0-alpha-1",
+ "1.0-alpha-9",
+ "1.0-alpha-10",
+ "1.0-alpha-22" } );
+
+ assertSort( new String[] { "1.0-alpha1", "1.0-alpha22", "1.0-alpha10", "1.0-alpha9" }, new String[] {
+ "1.0-alpha1",
+ "1.0-alpha9",
+ "1.0-alpha10",
+ "1.0-alpha22" } );
+
+ assertSort( new String[] { "1.0-1", "1.0-22", "1.0-10", "1.0-9" }, new String[] {
+ "1.0-1",
+ "1.0-9",
+ "1.0-10",
+ "1.0-22" } );
+
+ assertSort( new String[] { "alpha-1", "alpha-22", "alpha-10", "alpha-9" }, new String[] {
+ "alpha-1",
+ "alpha-9",
+ "alpha-10",
+ "alpha-22" } );
+
+ assertSort( new String[] { "1.0.1", "1.0.22", "1.0.10", "1.0.9" }, new String[] {
+ "1.0.1",
+ "1.0.9",
+ "1.0.10",
+ "1.0.22" } );
+
+
+ // TODO: write more unit tests.
+ }
+
+ private void assertSort( String[] rawVersions, String[] expectedSort )
+ {
+ List versions = new ArrayList();
+ versions.addAll( Arrays.asList( rawVersions ) );
+
+ Collections.sort( versions, VersionComparator.getInstance() );
+
+ assertEquals( "Versions.size()", expectedSort.length, versions.size() );
+ for ( int i = 0; i < expectedSort.length; i++ )
+ {
+ assertEquals( "Sorted Versions[" + i + "]", expectedSort[i], (String) versions.get( i ) );
+ }
+ }
+
+ public void testToParts()
+ {
+ assertParts( "1.0", new String[] { "1", "0" } );
+ assertParts( "1.0-alpha-1", new String[] { "1", "0", "alpha", "1" } );
+ assertParts( "2.0-rc2", new String[] { "2", "0", "rc", "2" } );
+ assertParts( "1.3-m6", new String[] { "1", "3", "m", "6" } );
+ }
+
+ private void assertParts( String version, String[] expectedParts )
+ {
+ String actualParts[] = VersionComparator.toParts( version );
+ assertEquals( "Parts.length", expectedParts.length, actualParts.length );
+
+ for ( int i = 0; i < expectedParts.length; i++ )
+ {
+ assertEquals( "parts[" + i + "]", expectedParts[i], actualParts[i] );
+ }
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root
new file mode 100644
index 000000000..2e65f24a6
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root
@@ -0,0 +1 @@
+not a real CVS root - for testing exclusions
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/KEYS b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/KEYS
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/no-extension b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/no-extension
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/CVS/Root b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/CVS/Root
new file mode 100644
index 000000000..2e65f24a6
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/CVS/Root
@@ -0,0 +1 @@
+not a real CVS root - for testing exclusions
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/KEYS b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/KEYS
new file mode 100644
index 000000000..d3b34d5ad
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/KEYS
@@ -0,0 +1 @@
+test KEYS file
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/invalid/invalid/1/invalid-1
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml
new file mode 100644
index 000000000..b3baf545d
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ javax.sql
+ jdbc
+ 2.0
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml
new file mode 100644
index 000000000..caf5b6697
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ javax.sql
+ jdbc
+ 2.0
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml
new file mode 100644
index 000000000..bb7570891
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml
@@ -0,0 +1,30 @@
+
+
+
+
+ javax.sql
+ jdbc
+ 2.0
+
+
+ 2.0
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml
new file mode 100644
index 000000000..caf5b6697
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ javax.sql
+ jdbc
+ 2.0
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom
new file mode 100644
index 000000000..202a0a448
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ A
+ 1.0
+ Maven Test Repository Artifact Discovery
+ war
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom
new file mode 100644
index 000000000..fa5f8f6c8
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ B
+ 1.0
+ Maven Test Repository Artifact Discovery
+ pom
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom
new file mode 100644
index 000000000..c3034e820
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ B
+ 2.0
+ Maven Test Repository Artifact Discovery
+ pom
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom
new file mode 100644
index 000000000..ae14cd7eb
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ C
+ 1.0
+ Maven Test Repository Artifact Discovery
+ war
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..5a29f6117
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ discovery
+ 1.0
+ Maven Test Repository Artifact Discovery
+ pom
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml
new file mode 100644
index 000000000..8ce7fc7bb
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ org.apache.maven
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
new file mode 100644
index 000000000..6ab57d162
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
@@ -0,0 +1,29 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ C
+ 1.0
+ Maven Test Repository Artifact Discovery
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
new file mode 100644
index 000000000..a959980df
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
@@ -0,0 +1,29 @@
+
+
+
+ 4.0.0
+ org.apache.maven
+ C
+ 1.0
+ Maven Test Repository Artifact Discovery
+
+ jar
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip
new file mode 100644
index 000000000..e69de29bb
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom
new file mode 100644
index 000000000..452727f28
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom
@@ -0,0 +1,29 @@
+
+
+
+ 4.0.0
+ org.apache.maven.update
+ test-not-updated
+ 1.0
+ Maven Test Repository Artifact Discovery
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml
new file mode 100644
index 000000000..bd56a21c1
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ org.apache.maven.update
+ test-not-updated
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom
new file mode 100644
index 000000000..edd7b6479
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom
@@ -0,0 +1,29 @@
+
+
+
+ 4.0.0
+ org.apache.maven.update
+ test-updated
+ 1.0
+ Maven Test Repository Artifact Discovery
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml
new file mode 100644
index 000000000..86e063ca8
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ org.apache.maven.update
+ test-updated
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..12538e81a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,28 @@
+
+
+
+ 4.0.0
+ org.apache.testgroup
+ discovery
+ 1.0
+ Maven Test Repository Artifact Discovery
+ pom
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml
new file mode 100644
index 000000000..8ee18048c
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ org.apache.testgroup
+ discovery
+ 1.0
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml
new file mode 100644
index 000000000..b024ef7ef
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ org.apache.testgroup
+ discovery
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar
new file mode 100644
index 000000000..d1b610e5e
Binary files /dev/null and b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar differ
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-bad b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-bad
new file mode 100644
index 000000000..aafbb1c77
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-bad
@@ -0,0 +1 @@
+444ccc111aaa222999888eee222fff00 artifact.jar
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-good b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-good
new file mode 100644
index 000000000..1c8465238
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.md5-good
@@ -0,0 +1 @@
+360ccd01d8a0a2d94b86f9802c2fc548 artifact.jar
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-bad b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-bad
new file mode 100644
index 000000000..2d809c29b
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-bad
@@ -0,0 +1 @@
+ddd888999000444888bbbaaa555333999777eee0 artifact.jar
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-good b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-good
new file mode 100644
index 000000000..0f10d257e
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/checksums/artifact.jar.sha1-good
@@ -0,0 +1 @@
+7dd8929150664f182db60ad15f20359d875f059f artifact.jar
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml
new file mode 100644
index 000000000..5760e8918
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ org.apache.maven.archiva.common.consumers.Consumer
+ mock-artifact
+ org.apache.maven.archiva.common.consumers.MockArtifactConsumer
+
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
+
+
+
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml
new file mode 100644
index 000000000..2ded1b62d
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ org.apache.maven.archiva.discoverer.DiscovererConsumer
+ mock-model
+ org.apache.maven.archiva.discoverer.consumers.MockModelConsumer
+
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
+
+
+
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml
new file mode 100644
index 000000000..da9864d00
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ org.apache.maven.archiva.discoverer.DiscovererConsumer
+ mock-metadata
+ org.apache.maven.archiva.discoverer.consumers.MockRepositoryMetadataConsumer
+
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
+
+
+
+
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/pom.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/pom.xml
new file mode 100644
index 000000000..2999766b9
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/pom.xml
@@ -0,0 +1,99 @@
+
+
+
+
+
+ org.apache.archiva
+ archiva-base
+ 1.2-SNAPSHOT
+
+ 4.0.0
+ archiva-configuration
+ Archiva Base :: Configuration
+
+
+ org.codehaus.plexus
+ plexus-spring
+ test
+
+
+ org.codehaus.plexus.registry
+ plexus-registry-api
+
+
+ org.codehaus.plexus.registry
+ plexus-registry-commons
+
+
+ org.codehaus.plexus
+ plexus-expression-evaluator
+
+
+ commons-io
+ commons-io
+
+
+ org.apache.archiva
+ archiva-policies
+
+
+ xmlunit
+ xmlunit
+ test
+
+
+
+
+
+ org.codehaus.modello
+ modello-maven-plugin
+ 1.0-alpha-15
+
+
+
+ java
+ registry-reader
+ registry-writer
+
+
+
+
+ 1.2.0
+ src/main/mdo/configuration.mdo
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+
+
+
+
+ org/apache/maven/archiva/configuration/io/**
+ org/apache/maven/archiva/configuration/*RepositoryConfiguration.*
+ org/apache/maven/archiva/configuration/Configuration.*
+ org/apache/maven/archiva/configuration/Proxy.*
+
+
+
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java
new file mode 100644
index 000000000..0705fd654
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java
@@ -0,0 +1,82 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.registry.RegistryListener;
+
+/**
+ * Configuration holder for the model read from the registry.
+ */
+public interface ArchivaConfiguration
+{
+ String ROLE = ArchivaConfiguration.class.getName();
+
+ /**
+ * Get the configuration.
+ *
+ * @return the configuration
+ */
+ Configuration getConfiguration();
+
+ /**
+ * Save any updated configuration.
+ *
+ * @param configuration the configuration to save
+ * @throws org.codehaus.plexus.registry.RegistryException
+ * if there is a problem saving the registry data
+ * @throws IndeterminateConfigurationException
+ * if the configuration cannot be saved because it was read from two sources
+ */
+ void save( Configuration configuration )
+ throws RegistryException, IndeterminateConfigurationException;
+
+ /**
+ * Determines if the configuration in use was as a result of a defaulted configuration.
+ *
+ * @return true if the configuration was created from the default-archiva.xml as opposed
+ * to being loaded from the usual locations of ${user.home}/.m2/archiva.xml or
+ * ${appserver.base}/conf/archiva.xml
+ */
+ boolean isDefaulted();
+
+ /**
+ * Add a configuration listener to notify of changes to the configuration.
+ *
+ * @param listener the listener
+ */
+ void addListener( ConfigurationListener listener );
+
+ /**
+ * Remove a configuration listener to stop notifications of changes to the configuration.
+ *
+ * @param listener the listener
+ */
+ void removeListener( ConfigurationListener listener );
+
+ /**
+ * Add a registry listener to notify of events in plexus-registry.
+ *
+ * @param listener the listener
+ * TODO: Remove in future.
+ */
+ void addChangeListener( RegistryListener listener );
+}
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationEvent.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationEvent.java
new file mode 100644
index 000000000..3105ee96e
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationEvent.java
@@ -0,0 +1,77 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ConfigurationEvent
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ConfigurationEvent
+{
+ public static final int SAVED = 1;
+
+ public static final int CHANGED = 2;
+
+ private int type;
+
+ public ConfigurationEvent( int type )
+ {
+ this.type = type;
+ }
+
+ public int getType()
+ {
+ return type;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + type;
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( obj == null )
+ {
+ return false;
+ }
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+ final ConfigurationEvent other = (ConfigurationEvent) obj;
+ if ( type != other.type )
+ {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java
new file mode 100644
index 000000000..f02637c83
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java
@@ -0,0 +1,34 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ConfigurationListener
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface ConfigurationListener
+{
+ /**
+ * Generic event point to notify components that something has happend in the configuration.
+ */
+ public void configurationEvent(ConfigurationEvent event);
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationNames.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationNames.java
new file mode 100644
index 000000000..e1daac902
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationNames.java
@@ -0,0 +1,69 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utility methods for testing the configuration property name.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ConfigurationNames
+{
+ public static boolean isNetworkProxy( String propertyName )
+ {
+ return startsWith( "networkProxies.", propertyName );
+ }
+
+ public static boolean isRepositoryScanning( String propertyName )
+ {
+ return startsWith( "repositoryScanning.", propertyName );
+ }
+
+ public static boolean isManagedRepositories( String propertyName )
+ {
+ return startsWith( "managedRepositories.", propertyName );
+ }
+
+ public static boolean isRemoteRepositories( String propertyName )
+ {
+ return startsWith( "remoteRepositories.", propertyName );
+ }
+
+ public static boolean isProxyConnector( String propertyName )
+ {
+ return startsWith( "proxyConnectors.", propertyName );
+ }
+
+ private static boolean startsWith( String prefix, String name )
+ {
+ if ( name == null )
+ {
+ return false;
+ }
+
+ if ( name.length() <= 0 )
+ {
+ return false;
+ }
+
+ return name.startsWith( prefix );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java
new file mode 100644
index 000000000..5fc44f80d
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Unrecoverable exception in the configuration mechanism that is the result of a programming error.
+ */
+public class ConfigurationRuntimeException
+ extends RuntimeException
+{
+ public ConfigurationRuntimeException( String msg, Throwable cause )
+ {
+ super( msg, cause );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
new file mode 100644
index 000000000..af3180d13
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
@@ -0,0 +1,736 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator;
+import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader;
+import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter;
+import org.apache.maven.archiva.policies.AbstractUpdatePolicy;
+import org.apache.maven.archiva.policies.CachedFailuresPolicy;
+import org.apache.maven.archiva.policies.ChecksumPolicy;
+import org.apache.maven.archiva.policies.Policy;
+import org.apache.maven.archiva.policies.PostDownloadPolicy;
+import org.apache.maven.archiva.policies.PreDownloadPolicy;
+import org.codehaus.plexus.evaluator.DefaultExpressionEvaluator;
+import org.codehaus.plexus.evaluator.EvaluatorException;
+import org.codehaus.plexus.evaluator.ExpressionEvaluator;
+import org.codehaus.plexus.evaluator.sources.SystemPropertyExpressionSource;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.registry.RegistryListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ *
+ * Implementation of configuration holder that retrieves it from the registry.
+ *
+ *
+ * The registry layers and merges the 2 configuration files: user, and application server.
+ *
+ *
+ * Instead of relying on the model defaults, if the registry is empty a default configuration file is loaded and
+ * applied from a resource. The defaults are not loaded into the registry as the lists (eg repositories) could no longer
+ * be removed if that was the case.
+ *
+ *
+ * When saving the configuration, it is saved to the location it was read from. If it was read from the defaults, it
+ * will be saved to the user location.
+ * However, if the configuration contains information from both sources, an exception is raised as this is currently
+ * unsupported. The reason for this is that it is not possible to identify where to re-save elements, and can result
+ * in list configurations (eg repositories) becoming inconsistent.
+ *
+ *
+ * If the configuration is outdated, it will be upgraded when it is loaded. This is done by checking the version flag
+ * before reading it from the registry.
+ *
+ *
+ * @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration"
+ */
+public class DefaultArchivaConfiguration
+ implements ArchivaConfiguration, RegistryListener, Initializable
+{
+ private Logger log = LoggerFactory.getLogger( DefaultArchivaConfiguration.class );
+
+ /**
+ * Plexus registry to read the configuration from.
+ *
+ * @plexus.requirement role-hint="commons-configuration"
+ */
+ private Registry registry;
+
+ /**
+ * The configuration that has been converted.
+ */
+ private Configuration configuration;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
+ * @todo these don't strictly belong in here
+ */
+ private Map prePolicies;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy"
+ * @todo these don't strictly belong in here
+ */
+ private Map postPolicies;
+
+ /**
+ * @plexus.configuration default-value="${user.home}/.m2/archiva.xml"
+ */
+ private String userConfigFilename;
+
+ /**
+ * @plexus.configuration default-value="${appserver.base}/conf/archiva.xml"
+ */
+ private String altConfigFilename;
+
+ /**
+ * Configuration Listeners we've registered.
+ */
+ private Set listeners = new HashSet();
+
+ /**
+ * Registry Listeners we've registered.
+ */
+ private Set registryListeners = new HashSet();
+
+ /**
+ * Boolean to help determine if the configuration exists as a result of pulling in
+ * the default-archiva.xml
+ */
+ private boolean isConfigurationDefaulted = false;
+
+ private static final String KEY = "org.apache.maven.archiva";
+
+ public synchronized Configuration getConfiguration()
+ {
+ if ( configuration == null )
+ {
+ configuration = load();
+ configuration = unescapeExpressions( configuration );
+ if( isConfigurationDefaulted )
+ {
+ configuration = checkRepositoryLocations( configuration );
+ }
+ }
+
+ return configuration;
+ }
+
+ private Configuration load()
+ {
+ // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties)
+ Registry subset = registry.getSubset( KEY );
+ if ( subset.getString( "version" ) == null )
+ {
+ // a little autodetection of v1, even if version is omitted (this was previously allowed)
+ if ( subset.getSubset( "repositoryScanning" ).isEmpty() )
+ {
+ // only for empty, or v < 1
+ subset = readDefaultConfiguration();
+ }
+ }
+
+ Configuration config = new ConfigurationRegistryReader().read( subset );
+
+ if ( !config.getRepositories().isEmpty() )
+ {
+ for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); )
+ {
+ V1RepositoryConfiguration r = i.next();
+ r.setScanned( r.isIndexed() );
+
+ if ( r.getUrl().startsWith( "file://" ) )
+ {
+ r.setLocation( r.getUrl().substring( 7 ) );
+ config.addManagedRepository( r );
+ }
+ else if ( r.getUrl().startsWith( "file:" ) )
+ {
+ r.setLocation( r.getUrl().substring( 5 ) );
+ config.addManagedRepository( r );
+ }
+ else
+ {
+ RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ repo.setId( r.getId() );
+ repo.setLayout( r.getLayout() );
+ repo.setName( r.getName() );
+ repo.setUrl( r.getUrl() );
+ config.addRemoteRepository( repo );
+ }
+ }
+
+ // Prevent duplicate repositories from showing up.
+ config.getRepositories().clear();
+
+ registry.removeSubset( KEY + ".repositories" );
+ }
+
+ if ( !CollectionUtils.isEmpty( config.getRemoteRepositories() ) )
+ {
+ List remoteRepos = config.getRemoteRepositories();
+ for ( RemoteRepositoryConfiguration repo : remoteRepos )
+ {
+ // [MRM-582] Remote Repositories with empty and fields shouldn't be created in configuration.
+ if ( StringUtils.isBlank( repo.getUsername() ) )
+ {
+ repo.setUsername( null );
+ }
+
+ if ( StringUtils.isBlank( repo.getPassword() ) )
+ {
+ repo.setPassword( null );
+ }
+ }
+ }
+
+ if ( !config.getProxyConnectors().isEmpty() )
+ {
+ // Fix Proxy Connector Settings.
+
+ List proxyConnectorList = new ArrayList();
+ // Create a copy of the list to read from (to prevent concurrent modification exceptions)
+ proxyConnectorList.addAll( config.getProxyConnectors() );
+ // Remove the old connector list.
+ config.getProxyConnectors().clear();
+
+ for ( ProxyConnectorConfiguration connector : proxyConnectorList )
+ {
+ // Fix policies
+ boolean connectorValid = true;
+
+ Map policies = new HashMap();
+ // Make copy of policies
+ policies.putAll( connector.getPolicies() );
+ // Clear out policies
+ connector.getPolicies().clear();
+
+ // Work thru policies. cleaning them up.
+ for ( Entry entry : policies.entrySet() )
+ {
+ String policyId = entry.getKey();
+ String setting = entry.getValue();
+
+ // Upgrade old policy settings.
+ if ( "releases".equals( policyId ) || "snapshots".equals( policyId ) )
+ {
+ if ( "ignored".equals( setting ) )
+ {
+ setting = AbstractUpdatePolicy.ALWAYS;
+ }
+ else if ( "disabled".equals( setting ) )
+ {
+ setting = AbstractUpdatePolicy.NEVER;
+ }
+ }
+ else if ( "cache-failures".equals( policyId ) )
+ {
+ if ( "ignored".equals( setting ) )
+ {
+ setting = CachedFailuresPolicy.NO;
+ }
+ else if ( "cached".equals( setting ) )
+ {
+ setting = CachedFailuresPolicy.YES;
+ }
+ }
+ else if ( "checksum".equals( policyId ) )
+ {
+ if ( "ignored".equals( setting ) )
+ {
+ setting = ChecksumPolicy.IGNORE;
+ }
+ }
+
+ // Validate existance of policy key.
+ if ( policyExists( policyId ) )
+ {
+ Policy policy = findPolicy( policyId );
+ // Does option exist?
+ if ( !policy.getOptions().contains( setting ) )
+ {
+ setting = policy.getDefaultOption();
+ }
+ connector.addPolicy( policyId, setting );
+ }
+ else
+ {
+ // Policy key doesn't exist. Don't add it to golden version.
+ log.warn( "Policy [" + policyId + "] does not exist." );
+ }
+ }
+
+ if ( connectorValid )
+ {
+ config.addProxyConnector( connector );
+ }
+ }
+
+ // Normalize the order fields in the proxy connectors.
+ Map> proxyConnectorMap = config
+ .getProxyConnectorAsMap();
+
+ for ( String key : proxyConnectorMap.keySet() )
+ {
+ List connectors = proxyConnectorMap.get( key );
+ // Sort connectors by order field.
+ Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance() );
+
+ // Normalize the order field values.
+ int order = 1;
+ for ( ProxyConnectorConfiguration connector : connectors )
+ {
+ connector.setOrder( order++ );
+ }
+ }
+ }
+
+ return config;
+ }
+
+ private Policy findPolicy( String policyId )
+ {
+ if ( MapUtils.isEmpty( prePolicies ) )
+ {
+ log.error( "No PreDownloadPolicies found!" );
+ return null;
+ }
+
+ if ( MapUtils.isEmpty( postPolicies ) )
+ {
+ log.error( "No PostDownloadPolicies found!" );
+ return null;
+ }
+
+ Policy policy;
+
+ policy = prePolicies.get( policyId );
+ if ( policy != null )
+ {
+ return policy;
+ }
+
+ policy = postPolicies.get( policyId );
+ if ( policy != null )
+ {
+ return policy;
+ }
+
+ return null;
+ }
+
+ private boolean policyExists( String policyId )
+ {
+ if ( MapUtils.isEmpty( prePolicies ) )
+ {
+ log.error( "No PreDownloadPolicies found!" );
+ return false;
+ }
+
+ if ( MapUtils.isEmpty( postPolicies ) )
+ {
+ log.error( "No PostDownloadPolicies found!" );
+ return false;
+ }
+
+ return ( prePolicies.containsKey( policyId ) || postPolicies.containsKey( policyId ) );
+ }
+
+ private Registry readDefaultConfiguration()
+ {
+ // if it contains some old configuration, remove it (Archiva 0.9)
+ registry.removeSubset( KEY );
+
+ try
+ {
+ registry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml", KEY );
+ this.isConfigurationDefaulted = true;
+ }
+ catch ( RegistryException e )
+ {
+ throw new ConfigurationRuntimeException(
+ "Fatal error: Unable to find the built-in default configuration and load it into the registry",
+ e );
+ }
+ return registry.getSubset( KEY );
+ }
+
+ public synchronized void save( Configuration configuration )
+ throws RegistryException, IndeterminateConfigurationException
+ {
+ Registry section = registry.getSection( KEY + ".user" );
+ Registry baseSection = registry.getSection( KEY + ".base" );
+ if ( section == null )
+ {
+ section = baseSection;
+ if ( section == null )
+ {
+ section = createDefaultConfigurationFile();
+ }
+ }
+ else if ( baseSection != null )
+ {
+ Collection keys = baseSection.getKeys();
+ boolean foundList = false;
+ for ( Iterator i = keys.iterator(); i.hasNext() && !foundList; )
+ {
+ String key = i.next();
+
+ // a little aggressive with the repositoryScanning and databaseScanning - should be no need to split
+ // that configuration
+ if ( key.startsWith( "repositories" ) || key.startsWith( "proxyConnectors" )
+ || key.startsWith( "networkProxies" ) || key.startsWith( "repositoryScanning" )
+ || key.startsWith( "databaseScanning" ) || key.startsWith( "remoteRepositories" )
+ || key.startsWith( "managedRepositories" ) || key.startsWith( "repositoryGroups" ) )
+ {
+ foundList = true;
+ }
+ }
+
+ if ( foundList )
+ {
+ this.configuration = null;
+
+ throw new IndeterminateConfigurationException(
+ "Configuration can not be saved when it is loaded from two sources" );
+ }
+ }
+
+ // escape all cron expressions to handle ','
+ escapeCronExpressions( configuration );
+
+ // [MRM-661] Due to a bug in the modello registry writer, we need to take these out by hand. They'll be put back by the writer.
+ if ( configuration.getManagedRepositories().isEmpty() )
+ {
+ section.removeSubset( "managedRepositories" );
+ }
+ if ( configuration.getRemoteRepositories().isEmpty() )
+ {
+ section.removeSubset( "remoteRepositories" );
+ }
+ if ( configuration.getProxyConnectors().isEmpty() )
+ {
+ section.removeSubset( "proxyConnectors" );
+ }
+ if ( configuration.getNetworkProxies().isEmpty() )
+ {
+ section.removeSubset( "networkProxies" );
+ }
+ if ( configuration.getLegacyArtifactPaths().isEmpty() )
+ {
+ section.removeSubset( "legacyArtifactPaths" );
+ }
+ if ( configuration.getRepositoryGroups().isEmpty() )
+ {
+ section.removeSubset( "repositoryGroups" );
+ }
+ if ( configuration.getRepositoryScanning() != null )
+ {
+ if ( configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty() )
+ {
+ section.removeSubset( "repositoryScanning.knownContentConsumers" );
+ }
+ if ( configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty() )
+ {
+ section.removeSubset( "repositoryScanning.invalidContentConsumers" );
+ }
+ }
+ if ( configuration.getDatabaseScanning() != null )
+ {
+ if ( configuration.getDatabaseScanning().getCleanupConsumers().isEmpty() )
+ {
+ section.removeSubset( "databaseScanning.cleanupConsumers" );
+ }
+ if ( configuration.getDatabaseScanning().getUnprocessedConsumers().isEmpty() )
+ {
+ section.removeSubset( "databaseScanning.unprocessedConsumers" );
+ }
+ }
+
+ new ConfigurationRegistryWriter().write( configuration, section );
+ section.save();
+
+ this.configuration = unescapeExpressions( configuration );
+
+ triggerEvent( ConfigurationEvent.SAVED );
+ }
+
+ private void escapeCronExpressions( Configuration configuration )
+ {
+ for ( ManagedRepositoryConfiguration c : (List) configuration.getManagedRepositories() )
+ {
+ c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) );
+ }
+
+ DatabaseScanningConfiguration scanning = configuration.getDatabaseScanning();
+ if ( scanning != null )
+ {
+ scanning.setCronExpression( escapeCronExpression( scanning.getCronExpression() ) );
+ }
+ }
+
+ private Registry createDefaultConfigurationFile()
+ throws RegistryException
+ {
+ // TODO: may not be needed under commons-configuration 1.4 - check
+ // UPDATE: Upgrading to commons-configuration 1.4 breaks half the unit tests. 2007-10-11 (joakime)
+
+ String contents = "";
+ if ( !writeFile( "user configuration", userConfigFilename, contents ) )
+ {
+ if ( !writeFile( "alternative configuration", altConfigFilename, contents ) )
+ {
+ throw new RegistryException( "Unable to create configuration file in either user ["
+ + userConfigFilename + "] or alternative [" + altConfigFilename
+ + "] locations on disk, usually happens when not allowed to write to those locations." );
+ }
+ }
+
+ try
+ {
+ ( (Initializable) registry ).initialize();
+
+ for ( RegistryListener regListener : registryListeners )
+ {
+ addRegistryChangeListener( regListener );
+ }
+ }
+ catch ( InitializationException e )
+ {
+ throw new RegistryException( "Unable to reinitialize configuration: " + e.getMessage(), e );
+ }
+
+ triggerEvent( ConfigurationEvent.SAVED );
+
+ return registry.getSection( KEY + ".user" );
+ }
+
+ /**
+ * Attempts to write the contents to a file, if an IOException occurs, return false.
+ *
+ * The file will be created if the directory to the file exists, otherwise this will return false.
+ *
+ * @param filetype the filetype (freeform text) to use in logging messages when failure to write.
+ * @param path the path to write to.
+ * @param contents the contents to write.
+ * @return true if write successful.
+ */
+ private boolean writeFile( String filetype, String path, String contents )
+ {
+ File file = new File( path );
+
+ try
+ {
+ // Check parent directory (if it is declared)
+ if ( file.getParentFile() != null )
+ {
+ // Check that directory exists
+ if ( ( file.getParentFile().exists() == false ) || ( file.getParentFile().isDirectory() == false ) )
+ {
+ // Directory to file must exist for file to be created
+ return false;
+ }
+ }
+
+ FileUtils.writeStringToFile( file, contents, "UTF-8" );
+ return true;
+ }
+ catch ( IOException e )
+ {
+ log.error( "Unable to create " + filetype + " file: " + e.getMessage(), e );
+ return false;
+ }
+ }
+
+ private void triggerEvent( int type )
+ {
+ ConfigurationEvent evt = new ConfigurationEvent( type );
+ for ( ConfigurationListener listener : listeners )
+ {
+ listener.configurationEvent( evt );
+ }
+ }
+
+ public void addListener( ConfigurationListener listener )
+ {
+ if ( listener == null )
+ {
+ return;
+ }
+
+ listeners.add( listener );
+ }
+
+ public void removeListener( ConfigurationListener listener )
+ {
+ if ( listener == null )
+ {
+ return;
+ }
+
+ listeners.remove( listener );
+ }
+
+ public void addChangeListener( RegistryListener listener )
+ {
+ addRegistryChangeListener( listener );
+
+ // keep track for later
+ registryListeners.add( listener );
+ }
+
+ private void addRegistryChangeListener( RegistryListener listener )
+ {
+ Registry section = registry.getSection( KEY + ".user" );
+ if ( section != null )
+ {
+ section.addChangeListener( listener );
+ }
+ section = registry.getSection( KEY + ".base" );
+ if ( section != null )
+ {
+ section.addChangeListener( listener );
+ }
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+ // Resolve expressions in the userConfigFilename and altConfigFilename
+ try
+ {
+ ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator();
+ expressionEvaluator.addExpressionSource( new SystemPropertyExpressionSource() );
+ userConfigFilename = expressionEvaluator.expand( userConfigFilename );
+ altConfigFilename = expressionEvaluator.expand( altConfigFilename );
+ }
+ catch ( EvaluatorException e )
+ {
+ throw new InitializationException( "Unable to evaluate expressions found in "
+ + "userConfigFilename or altConfigFilename." );
+ }
+
+ registry.addChangeListener( this );
+ }
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ // nothing to do here
+ }
+
+ public synchronized void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ configuration = null;
+ }
+
+ private String removeExpressions( String directory )
+ {
+ String value = StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base",
+ "${appserver.base}" ) );
+ value = StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home",
+ "${appserver.home}" ) );
+ return value;
+ }
+
+ private String unescapeCronExpression( String cronExpression )
+ {
+ return StringUtils.replace( cronExpression, "\\,", "," );
+ }
+
+ private String escapeCronExpression( String cronExpression )
+ {
+ return StringUtils.replace( cronExpression, ",", "\\," );
+ }
+
+ private Configuration unescapeExpressions( Configuration config )
+ {
+ // TODO: for commons-configuration 1.3 only
+ for ( Iterator i = config.getManagedRepositories().iterator(); i.hasNext(); )
+ {
+ ManagedRepositoryConfiguration c = i.next();
+ c.setLocation( removeExpressions( c.getLocation() ) );
+ c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) );
+ }
+
+ DatabaseScanningConfiguration databaseScanning = config.getDatabaseScanning();
+ if ( databaseScanning != null )
+ {
+ String cron = databaseScanning.getCronExpression();
+ databaseScanning.setCronExpression( unescapeCronExpression( cron ) );
+ }
+
+ return config;
+ }
+
+ private Configuration checkRepositoryLocations( Configuration config )
+ {
+ // additional check for [MRM-789], ensure that the location of the default repositories
+ // are not installed in the server installation
+ for( ManagedRepositoryConfiguration repo : (List) config.getManagedRepositories() )
+ {
+ String repoPath = repo.getLocation();
+ File repoLocation = new File( repoPath );
+
+ if( repoLocation.exists() && repoLocation.isDirectory() && !repoPath.endsWith( "data/repositories/" + repo.getId() ) )
+ {
+ repo.setLocation( repoPath + "/data/repositories/" + repo.getId() );
+ }
+ }
+
+ return config;
+ }
+
+ public String getUserConfigFilename()
+ {
+ return userConfigFilename;
+ }
+
+ public String getAltConfigFilename()
+ {
+ return altConfigFilename;
+ }
+
+ public boolean isDefaulted()
+ {
+ return this.isConfigurationDefaulted;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
new file mode 100644
index 000000000..66be709b6
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
@@ -0,0 +1,252 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.configuration.CombinedConfiguration;
+import org.apache.maven.archiva.common.utils.Slf4JPlexusLogger;
+import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate;
+import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.registry.RegistryListener;
+import org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry;
+import org.codehaus.plexus.util.SelectorUtils;
+
+/**
+ * FileTypes
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ *
+ * @plexus.component role="org.apache.maven.archiva.configuration.FileTypes"
+ */
+public class FileTypes
+ implements Initializable, RegistryListener
+{
+ public static final String ARTIFACTS = "artifacts";
+
+ public static final String AUTO_REMOVE = "auto-remove";
+
+ public static final String INDEXABLE_CONTENT = "indexable-content";
+
+ public static final String IGNORED = "ignored";
+
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaConfiguration archivaConfiguration;
+
+ /**
+ * Map of default values for the file types.
+ */
+ private Map> defaultTypeMap = new HashMap>();
+
+ private List artifactPatterns;
+
+ /**
+ * Default exclusions from artifact consumers that are using the file types. Note that this is simplistic in the
+ * case of the support files (based on extension) as it is elsewhere - it may be better to match these to actual
+ * artifacts and exclude later during scanning.
+ */
+ public static final List DEFAULT_EXCLUSIONS = Arrays.asList( "**/maven-metadata.xml",
+ "**/maven-metadata-*.xml", "**/*.sha1",
+ "**/*.asc", "**/*.md5", "**/*.pgp" );
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
+
+ /**
+ *
+ * Get the list of patterns for a specified filetype.
+ *
+ *
+ *
+ * You will always get a list. In this order.
+ *
+ * - The Configured List
+ * - The Default List
+ * - A single item list of
"**/*"
+ *
+ *
+ *
+ * @param id the id to lookup.
+ * @return the list of patterns.
+ */
+ public List getFileTypePatterns( String id )
+ {
+ Configuration config = archivaConfiguration.getConfiguration();
+ Predicate selectedFiletype = new FiletypeSelectionPredicate( id );
+ FileType filetype = (FileType) CollectionUtils.find( config.getRepositoryScanning().getFileTypes(),
+ selectedFiletype );
+
+ if ( ( filetype != null ) && CollectionUtils.isNotEmpty( filetype.getPatterns() ) )
+ {
+ return filetype.getPatterns();
+ }
+
+ List defaultPatterns = defaultTypeMap.get( id );
+
+ if ( CollectionUtils.isEmpty( defaultPatterns ) )
+ {
+ return Collections.singletonList( "**/*" );
+ }
+
+ return defaultPatterns;
+ }
+
+ public synchronized boolean matchesArtifactPattern( String relativePath )
+ {
+ // Correct the slash pattern.
+ relativePath = relativePath.replace( '\\', '/' );
+
+ if ( artifactPatterns == null )
+ {
+ artifactPatterns = getFileTypePatterns( ARTIFACTS );
+ }
+
+ for ( String pattern : artifactPatterns )
+ {
+ if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
+ {
+ // Found match
+ return true;
+ }
+ }
+
+ // No match.
+ return false;
+ }
+
+ public boolean matchesDefaultExclusions( String relativePath )
+ {
+ // Correct the slash pattern.
+ relativePath = relativePath.replace( '\\', '/' );
+
+ for ( String pattern : DEFAULT_EXCLUSIONS )
+ {
+ if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
+ {
+ // Found match
+ return true;
+ }
+ }
+
+ // No match.
+ return false;
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+ // TODO: why is this done by hand?
+
+ // TODO: ideally, this would be instantiated by configuration instead, and not need to be a component
+
+ String errMsg = "Unable to load default archiva configuration for FileTypes: ";
+
+ try
+ {
+ CommonsConfigurationRegistry commonsRegistry = new CommonsConfigurationRegistry();
+
+ // Configure commonsRegistry
+ Field fld = commonsRegistry.getClass().getDeclaredField( "configuration" );
+ fld.setAccessible( true );
+ fld.set( commonsRegistry, new CombinedConfiguration() );
+ commonsRegistry.enableLogging( new Slf4JPlexusLogger( FileTypes.class ) );
+ commonsRegistry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml" );
+
+ // Read configuration as it was intended.
+ ConfigurationRegistryReader configReader = new ConfigurationRegistryReader();
+ Configuration defaultConfig = configReader.read( commonsRegistry );
+
+ initialiseTypeMap( defaultConfig );
+ }
+ catch ( RegistryException e )
+ {
+ throw new InitializationException( errMsg + e.getMessage(), e );
+ }
+ catch ( SecurityException e )
+ {
+ throw new InitializationException( errMsg + e.getMessage(), e );
+ }
+ catch ( NoSuchFieldException e )
+ {
+ throw new InitializationException( errMsg + e.getMessage(), e );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ throw new InitializationException( errMsg + e.getMessage(), e );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new InitializationException( errMsg + e.getMessage(), e );
+ }
+
+ this.archivaConfiguration.addChangeListener( this );
+ }
+
+ private void initialiseTypeMap( Configuration configuration )
+ {
+ defaultTypeMap.clear();
+
+ // Store the default file type declaration.
+ List filetypes = configuration.getRepositoryScanning().getFileTypes();
+ for ( FileType filetype : filetypes )
+ {
+ List patterns = defaultTypeMap.get( filetype.getId() );
+ if ( patterns == null )
+ {
+ patterns = new ArrayList();
+ }
+ patterns.addAll( filetype.getPatterns() );
+
+ defaultTypeMap.put( filetype.getId(), patterns );
+ }
+ }
+
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ if ( propertyName.contains( "fileType" ) )
+ {
+ artifactPatterns = null;
+
+ initialiseTypeMap( archivaConfiguration.getConfiguration() );
+ }
+ }
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ /* nothing to do */
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java
new file mode 100644
index 000000000..97d5fbdf2
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Occurs when the configuration is stored in two locations and the save location can not be determined.
+ */
+public class IndeterminateConfigurationException
+ extends Exception
+{
+ public IndeterminateConfigurationException( String message )
+ {
+ super( message );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java
new file mode 100644
index 000000000..0efcde250
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java
@@ -0,0 +1,49 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * An error in the configuration.
+ *
+ * @author Brett Porter
+ */
+public class InvalidConfigurationException
+ extends Exception
+{
+ private final String name;
+
+ public InvalidConfigurationException( String name, String message )
+ {
+ super( message );
+ this.name = name;
+ }
+
+ public InvalidConfigurationException( String name, String message, Throwable cause )
+ {
+ super( message, cause );
+
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
new file mode 100644
index 000000000..e48b2d39a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
@@ -0,0 +1,154 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * @author Ben Walding
+ * @author Brett Porter
+ */
+public class MavenProxyPropertyLoader
+{
+ private static final String REPO_LOCAL_STORE = "repo.local.store";
+
+ private static final String PROXY_LIST = "proxy.list";
+
+ private static final String REPO_LIST = "repo.list";
+
+ public void load( Properties props, Configuration configuration )
+ throws InvalidConfigurationException
+ {
+ // set up the managed repository
+ String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE );
+
+ ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
+ config.setLocation( localCachePath );
+ config.setName( "Imported Maven-Proxy Cache" );
+ config.setId( "maven-proxy" );
+ config.setScanned( false );
+ config.setReleases( true );
+ config.setSnapshots( false );
+ configuration.addManagedRepository( config );
+
+ // Add the network proxies.
+ String propertyList = props.getProperty( PROXY_LIST );
+ if ( propertyList != null )
+ {
+ StringTokenizer tok = new StringTokenizer( propertyList, "," );
+ while ( tok.hasMoreTokens() )
+ {
+ String key = tok.nextToken();
+ if ( StringUtils.isNotEmpty( key ) )
+ {
+ NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
+ proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) );
+ proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) );
+
+ // the username and password isn't required
+ proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) );
+ proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) );
+
+ configuration.addNetworkProxy( proxy );
+ }
+ }
+ }
+
+ // Add the remote repository list
+ String repoList = getMandatoryProperty( props, REPO_LIST );
+
+ StringTokenizer tok = new StringTokenizer( repoList, "," );
+ while ( tok.hasMoreTokens() )
+ {
+ String key = tok.nextToken();
+
+ Properties repoProps = getSubset( props, "repo." + key + "." );
+ String url = getMandatoryProperty( props, "repo." + key + ".url" );
+ String proxyKey = repoProps.getProperty( "proxy" );
+
+ int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) );
+
+ RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration();
+ repository.setId( key );
+ repository.setName( "Imported Maven-Proxy Remote Proxy" );
+ repository.setUrl( url );
+ repository.setLayout( "legacy" );
+
+ configuration.addRemoteRepository( repository );
+
+ ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
+ proxyConnector.setSourceRepoId( "maven-proxy" );
+ proxyConnector.setTargetRepoId( key );
+ proxyConnector.setProxyId( proxyKey );
+ // TODO: convert cachePeriod to closest "daily" or "hourly"
+ proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY );
+ proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS );
+
+ configuration.addProxyConnector( proxyConnector );
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private Properties getSubset( Properties props, String prefix )
+ {
+ Enumeration keys = props.keys();
+ Properties result = new Properties();
+ while ( keys.hasMoreElements() )
+ {
+ String key = (String) keys.nextElement();
+ String value = props.getProperty( key );
+ if ( key.startsWith( prefix ) )
+ {
+ String newKey = key.substring( prefix.length() );
+ result.setProperty( newKey, value );
+ }
+ }
+ return result;
+ }
+
+ 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
+ {
+ String value = props.getProperty( key );
+
+ if ( value == null )
+ {
+ throw new InvalidConfigurationException( key, "Missing required field: " + key );
+ }
+
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeSelectionPredicate.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeSelectionPredicate.java
new file mode 100644
index 000000000..cfbe58fbe
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeSelectionPredicate.java
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.FileType;
+
+/**
+ * FiletypeSelectionPredicate
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class FiletypeSelectionPredicate
+ implements Predicate
+{
+ private String filetypeId;
+
+ public FiletypeSelectionPredicate( String id )
+ {
+ this.filetypeId = id;
+ }
+
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof FileType )
+ {
+ FileType filetype = (FileType) object;
+ return ( StringUtils.equals( filetypeId, filetype.getId() ) );
+ }
+
+ return satisfies;
+ }
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java
new file mode 100644
index 000000000..96f15ab2a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java
@@ -0,0 +1,52 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Closure;
+import org.apache.maven.archiva.configuration.FileType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * FiletypeToMapClosure
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class FiletypeToMapClosure
+ implements Closure
+{
+ private Map map = new HashMap();
+
+ public void execute( Object input )
+ {
+ if ( input instanceof FileType )
+ {
+ FileType filetype = (FileType) input;
+ map.put( filetype.getId(), filetype );
+ }
+ }
+
+ public Map getMap()
+ {
+ return map;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java
new file mode 100644
index 000000000..aebc924ba
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java
@@ -0,0 +1,56 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
+
+import java.util.Comparator;
+
+/**
+ * NetworkProxyComparator
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class NetworkProxyComparator
+ implements Comparator
+{
+ public int compare( NetworkProxyConfiguration o1, NetworkProxyConfiguration o2 )
+ {
+ if ( o1 == null && o2 == null )
+ {
+ return 0;
+ }
+
+ if ( o1 == null && o2 != null )
+ {
+ return 1;
+ }
+
+ if ( o1 != null && o2 == null )
+ {
+ return -1;
+ }
+
+ String id1 = o1.getId();
+ String id2 = o2.getId();
+ return id1.compareToIgnoreCase( id2 );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxySelectionPredicate.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxySelectionPredicate.java
new file mode 100644
index 000000000..b89828307
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxySelectionPredicate.java
@@ -0,0 +1,54 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
+
+/**
+ * NetworkProxySelectionPredicate
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class NetworkProxySelectionPredicate
+ implements Predicate
+{
+ private String proxyId;
+
+ public NetworkProxySelectionPredicate( String id )
+ {
+ this.proxyId = id;
+ }
+
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof NetworkProxyConfiguration )
+ {
+ NetworkProxyConfiguration proxy = (NetworkProxyConfiguration) object;
+ return ( StringUtils.equals( proxyId, proxy.getId() ) );
+ }
+
+ return satisfies;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
new file mode 100644
index 000000000..6c6cffe6f
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
@@ -0,0 +1,73 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+import java.util.Comparator;
+
+/**
+ * ProxyConnectorConfigurationOrderComparator
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ProxyConnectorConfigurationOrderComparator
+ implements Comparator
+{
+ private static ProxyConnectorConfigurationOrderComparator INSTANCE = new ProxyConnectorConfigurationOrderComparator();
+
+ public int compare( ProxyConnectorConfiguration o1, ProxyConnectorConfiguration o2 )
+ {
+ if ( o1 == null && o2 == null )
+ {
+ return 0;
+ }
+
+ // Ensure null goes to end of list.
+ if ( o1 == null && o2 != null )
+ {
+ return 1;
+ }
+
+ if ( o1 != null && o2 == null )
+ {
+ return -1;
+ }
+
+ // Ensure 0 (unordered) goes to end of list.
+ if ( o1.getOrder() == 0 && o2.getOrder() != 0 )
+ {
+ return 1;
+ }
+
+ if ( o1.getOrder() != 0 && o2.getOrder() == 0 )
+ {
+ return -1;
+ }
+
+ return o1.getOrder() - o2.getOrder();
+ }
+
+ public static ProxyConnectorConfigurationOrderComparator getInstance()
+ {
+ return INSTANCE;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
new file mode 100644
index 000000000..af18c6c5f
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
@@ -0,0 +1,59 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+/**
+ * ProxyConnectorPredicate
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ProxyConnectorSelectionPredicate
+ implements Predicate
+{
+ private String sourceId;
+
+ private String targetId;
+
+ public ProxyConnectorSelectionPredicate( String sourceId, String targetId )
+ {
+ this.sourceId = sourceId;
+ this.targetId = targetId;
+ }
+
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof ProxyConnectorConfiguration )
+ {
+ ProxyConnectorConfiguration connector = (ProxyConnectorConfiguration) object;
+ return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) && StringUtils
+ .equals( targetId, connector.getTargetRepoId() ) );
+ }
+
+ return satisfies;
+ }
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparator.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparator.java
new file mode 100644
index 000000000..caf99d343
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparator.java
@@ -0,0 +1,54 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
+
+import java.util.Comparator;
+
+/**
+ * RepositoryConfigurationComparator
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class RepositoryConfigurationComparator
+ implements Comparator
+{
+ public int compare( AbstractRepositoryConfiguration o1, AbstractRepositoryConfiguration o2 )
+ {
+ if ( o1 == null && o2 == null )
+ {
+ return 0;
+ }
+
+ if ( o1 == null )
+ {
+ return -1;
+ }
+
+ if ( o2 == null )
+ {
+ return 1;
+ }
+
+ return o1.getId().compareToIgnoreCase( o2.getId() );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
new file mode 100644
index 000000000..b7523ef13
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
@@ -0,0 +1,1127 @@
+
+
+
+
+ configuration
+ Configuration
+
+ Configuration for the Maven Repository Manager.
+
+
+
+ package
+ org.apache.maven.archiva.configuration
+
+
+
+
+ Configuration
+ 1.0.0+
+
+
+ version
+ 1.0.0+
+ String
+ true
+ This is the version of the configuration format.
+
+
+
+ @deprecated use managedRepositories or remoteRepositories instead.
+
+ repositories
+ 1.0.0+
+
+ V1RepositoryConfiguration
+ *
+
+
+
+ repositoryGroups
+ 1.2.0+
+
+ RepositoryGroupConfiguration
+ *
+
+ The list of repository groups.
+
+
+ managedRepositories
+ 1.0.0+
+
+ ManagedRepositoryConfiguration
+ *
+
+ The list of repositories that this archiva instance uses.
+
+
+ remoteRepositories
+ 1.0.0+
+
+ RemoteRepositoryConfiguration
+ *
+
+ The list of repositories that this archiva can retrieve from or publish to.
+
+
+ proxyConnectors
+ 1.0.0+
+
+ ProxyConnectorConfiguration
+ *
+
+ The list of proxy connectors for this archiva instance.
+
+
+
+ networkProxies
+ 1.0.0+
+
+ NetworkProxyConfiguration
+ *
+
+
+ The list of network proxies to use for outgoing requests.
+
+
+
+ legacyArtifactPaths
+ 1.1.0+
+
+ LegacyArtifactPath
+ *
+
+
+ The list of custom legacy path to artifact.
+
+
+
+ repositoryScanning
+ 1.0.0+
+
+ RepositoryScanningConfiguration
+ 1
+
+
+ The repository scanning configuration.
+
+
+
+ databaseScanning
+ 1.0.0+
+
+ DatabaseScanningConfiguration
+ 1
+
+
+ The database scanning configuration.
+
+
+
+ webapp
+ 1.0.0+
+
+ WebappConfiguration
+ 1
+
+
+ The webapp configuration.
+
+
+
+ organisationInfo
+ 1.1.0+
+
+ OrganisationInformation
+ 1
+
+
+ The organisation info.
+
+
+
+
+
+ 1.2.0+
+ > repositoryToGroupMap;
+
+ public java.util.Map> getRepositoryToGroupMap()
+ {
+ if ( repositoryGroups != null )
+ {
+ java.util.Map> map = new java.util.HashMap>();
+
+ for ( RepositoryGroupConfiguration group : (java.util.List) repositoryGroups )
+ {
+ for ( String repositoryId : (java.util.List) group.getRepositories() )
+ {
+ java.util.List groups = map.get( repositoryId );
+ if ( groups == null )
+ {
+ groups = new java.util.ArrayList();
+ map.put( repositoryId, groups );
+ }
+ groups.add( group.getId() );
+ }
+ }
+
+ repositoryToGroupMap = map;
+ }
+ return repositoryToGroupMap;
+ }
+
+ public java.util.Map getRepositoryGroupsAsMap()
+ {
+ java.util.Map map = new java.util.HashMap();
+ if ( repositoryGroups != null )
+ {
+ for ( RepositoryGroupConfiguration group : (java.util.List) repositoryGroups )
+ {
+ map.put( group.getId(), group );
+ }
+ }
+ return map;
+ }
+
+ public RepositoryGroupConfiguration findRepositoryGroupById( String id )
+ {
+ if ( repositoryGroups != null )
+ {
+ for ( RepositoryGroupConfiguration group : (java.util.List) repositoryGroups )
+ {
+ if ( group.getId().equals( id ) )
+ {
+ return group;
+ }
+ }
+ }
+ return null;
+ }
+
+ private java.util.Map> groupToRepositoryMap;
+
+ public java.util.Map> getGroupToRepositoryMap()
+ {
+ if ( repositoryGroups != null && managedRepositories != null )
+ {
+ java.util.Map> map = new java.util.HashMap>();
+
+ for ( ManagedRepositoryConfiguration repo : (java.util.List) managedRepositories )
+ {
+ for ( RepositoryGroupConfiguration group : (java.util.List) repositoryGroups )
+ {
+ if ( !group.getRepositories().contains( repo.getId() ) )
+ {
+ String groupId = group.getId();
+ java.util.List repos = map.get( groupId );
+ if ( repos == null )
+ {
+ repos = new java.util.ArrayList();
+ map.put( groupId, repos );
+ }
+ repos.add( repo.getId() );
+ }
+ }
+ }
+ groupToRepositoryMap = map;
+ }
+ return groupToRepositoryMap;
+ }
+ ]]>
+
+
+ 1.0.0+
+ getNetworkProxiesAsMap()
+ {
+ java.util.Map map = new java.util.HashMap();
+ if ( networkProxies != null )
+ {
+ for ( java.util.Iterator i = networkProxies.iterator(); i.hasNext(); )
+ {
+ NetworkProxyConfiguration proxy = i.next();
+ map.put( proxy.getId(), proxy );
+ }
+ }
+ return map;
+ }
+
+ public java.util.Map> getProxyConnectorAsMap()
+ {
+ java.util.Map> proxyConnectorMap =
+ new java.util.HashMap>();
+
+ java.util.Iterator it = proxyConnectors.iterator();
+ while ( it.hasNext() )
+ {
+ ProxyConnectorConfiguration proxyConfig = it.next();
+ String key = proxyConfig.getSourceRepoId();
+
+ java.util.List connectors = proxyConnectorMap.get( key );
+ if ( connectors == null )
+ {
+ connectors = new java.util.ArrayList();
+ proxyConnectorMap.put( key, connectors );
+ }
+
+ connectors.add( proxyConfig );
+ java.util.Collections.sort( connectors,
+ org.apache.maven.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator.getInstance() );
+ }
+
+ return proxyConnectorMap;
+ }
+
+ public java.util.Map getRemoteRepositoriesAsMap()
+ {
+ java.util.Map map = new java.util.HashMap();
+ if ( remoteRepositories != null )
+ {
+ for ( java.util.Iterator i = remoteRepositories.iterator(); i.hasNext(); )
+ {
+ RemoteRepositoryConfiguration repo = i.next();
+ map.put( repo.getId(), repo );
+ }
+ }
+ return map;
+ }
+
+ public RemoteRepositoryConfiguration findRemoteRepositoryById( String id )
+ {
+ if ( remoteRepositories != null )
+ {
+ for ( java.util.Iterator i = remoteRepositories.iterator(); i.hasNext(); )
+ {
+ RemoteRepositoryConfiguration repo = i.next();
+ if ( repo.getId().equals( id ) )
+ {
+ return repo;
+ }
+ }
+ }
+ return null;
+ }
+
+ public java.util.Map getManagedRepositoriesAsMap()
+ {
+ java.util.Map map = new java.util.HashMap();
+ if ( managedRepositories != null )
+ {
+ for ( java.util.Iterator i = managedRepositories.iterator(); i.hasNext(); )
+ {
+ ManagedRepositoryConfiguration repo = i.next();
+ map.put( repo.getId(), repo );
+ }
+ }
+ return map;
+ }
+
+ public ManagedRepositoryConfiguration findManagedRepositoryById( String id )
+ {
+ if ( managedRepositories != null )
+ {
+ for ( java.util.Iterator i = managedRepositories.iterator(); i.hasNext(); )
+ {
+ ManagedRepositoryConfiguration repo = i.next();
+ if ( repo.getId().equals( id ) )
+ {
+ return repo;
+ }
+ }
+ }
+ return null;
+ }
+ ]]>
+
+
+
+
+
+
+
+ AbstractRepositoryConfiguration
+ 1.0.0+
+ true
+
+
+ id
+ 1.0.0+
+ String
+ true
+
+ The repository identifier.
+
+
+
+ name
+ 1.0.0+
+ String
+ true
+
+ The descriptive name of the repository.
+
+
+
+ layout
+ 1.0.0+
+ String
+ true
+
+ The layout of the repository. Valid values are "default" and "legacy".
+
+
+ default
+
+
+
+
+ RemoteRepositoryConfiguration
+ 1.0.0+
+ AbstractRepositoryConfiguration
+
+
+ url
+ 1.0.0+
+ String
+ true
+
+ The URL for this repository.
+
+
+
+ username
+ 1.0.0+
+ String
+
+ The Username for this repository.
+
+
+
+ password
+ 1.0.0+
+ String
+
+ The Password for this repository.
+
+
+
+ timeout
+ 1.0.1+
+ int
+
+ Timeout in seconds for connections to this repository
+
+ 60
+
+
+
+
+ ManagedRepositoryConfiguration
+ 1.0.0+
+ AbstractRepositoryConfiguration
+
+
+ location
+ 1.0.0+
+ String
+ true
+
+ The file system location for this repository.
+
+
+
+ releases
+ 1.0.0+
+ boolean
+ True if this repository contains release versioned artifacts.
+ true
+
+
+ snapshots
+ 1.0.0+
+ boolean
+ True if this repository contains snapshot versioned artifacts.
+ false
+
+
+ scanned
+ 1.0.0+
+ boolean
+ True if this repository should be scanned and processed.
+ true
+
+
+ indexDir
+ 1.0.0+
+ String
+
+ The directory for the indexes of this repository.
+
+
+
+ refreshCronExpression
+ 1.0.0+
+ String
+
+ When to run the refresh task.
+ Default is every hour
+
+ 0 0 * * * ?
+
+
+ retentionCount
+ 1.0.0+
+ int
+
+ The total count of the artifact to be retained for each snapshot.
+
+ 2
+
+
+ daysOlder
+ 1.0.0+
+ int
+
+ The number of days old which will be the basis for removing a snapshot.
+
+ 100
+
+
+ deleteReleasedSnapshots
+ 1.0.0+
+ boolean
+
+ True if the released snapshots are to be removed from the repo during repository purge.
+
+ false
+
+
+
+
+ V1RepositoryConfiguration
+ 1.0.0+
+ ManagedRepositoryConfiguration
+
+
+ url
+ 1.0.0+
+ String
+ true
+
+ The URL for this repository.
+
+
+
+ indexed
+ 1.0.0+
+ boolean
+ true
+
+
+
+
+
+ LegacyArtifactPath
+ 1.1.0+
+
+
+ path
+ 1.1.0+
+ String
+ true
+
+ The legacy path.
+
+
+
+ artifact
+ 1.1.0+
+ String
+ true
+
+ The artifact reference, as " [groupId] : [artifactId] : [version] : [classifier] : [type] ".
+
+
+
+
+
+ 1.0.0+
+ 0 ? classifier : null;
+ }
+
+ public String getType()
+ {
+ return artifact.split( ":" )[4];
+ }
+ ]]>
+
+
+
+
+ RepositoryGroupConfiguration
+ 1.2.0+
+
+
+ id
+ 1.2.0+
+ String
+ true
+ The id of the repository group.
+
+
+ repositories
+ 1.2.0+
+
+ String
+ *
+
+ The list of repository ids under the group.
+
+
+
+
+
+
+
+ AbstractRepositoryConnectorConfiguration
+ true
+ 1.0.0+
+
+
+ sourceRepoId
+ 1.0.0+
+ String
+ true
+
+ The Repository Source for this connector.
+
+
+
+ targetRepoId
+ 1.0.0+
+ String
+ true
+
+ The Repository Target for this connector.
+
+
+
+ proxyId
+ 1.0.0+
+ String
+
+ The network proxy ID to use for this connector.
+
+
+
+ blackListPatterns
+ 1.0.0+
+
+ String
+ *
+
+
+ The list of blacklisted patterns for this connector.
+
+
+
+ whiteListPatterns
+ 1.0.0+
+
+ String
+ *
+
+
+ The list of whitelisted patterns for this connector.
+
+
+
+ policies
+ 1.0.0+
+ Map
+ Policy configuration for the connector.
+
+ String
+ *
+
+
+
+ properties
+ 1.0.0+
+ Map
+ Configuration for the connector.
+
+ String
+ *
+
+
+
+
+
+ 1.0.0+
+
+
+
+
+
+
+ AbstractRepositoryConnectorConfiguration
+ ProxyConnectorConfiguration
+ 1.0.0+
+
+
+ order
+ 1.0.0+
+
+ The order of the proxy connectors. (0 means no order specified)
+
+ int
+ 0
+
+
+
+
+ 1.0.0+
+
+
+
+
+
+
+ AbstractRepositoryConnectorConfiguration
+ SyncConnectorConfiguration
+ true
+ 1.0.0+
+
+
+ cronExpression
+ 1.0.0+
+ String
+ When to run the sync mechanism. Default is every hour on the hour.
+ 0 0 * * * ?
+
+
+ method
+ 1.0.0+
+ String
+ The type of synchronization to use.
+ rsync
+
+
+
+
+
+
+
+ NetworkProxyConfiguration
+ 1.0.0+
+
+
+ id
+ 1.0.0+
+ String
+
+ The ID for this proxy.
+
+
+
+ protocol
+ 1.0.0+
+
+ The network protocol to use with this proxy: "http", "socks-4"
+
+ String
+ true
+ http
+
+
+ host
+ 1.0.0+
+
+ The proxy host.
+
+ String
+ true
+
+
+ port
+ 1.0.0+
+
+ The proxy port.
+
+ int
+ 8080
+
+
+ username
+ 1.0.0+
+
+ The proxy user.
+
+ String
+
+
+ password
+ 1.0.0+
+
+ The proxy password.
+
+ String
+
+
+
+
+
+
+ RepositoryScanningConfiguration
+ 1.0.0+
+
+
+ fileTypes
+ 1.0.0+
+ true
+
+ FileType
+ *
+
+
+ The FileTypes for the repository scanning configuration.
+
+
+
+ knownContentConsumers
+ 1.0.0+
+ true
+
+ String
+ *
+
+
+ The list of active consumers IDs for known content.
+
+
+
+ invalidContentConsumers
+ 1.0.0+
+ true
+
+ String
+ *
+
+
+ The list of active consumer IDs for invalid content.
+
+
+
+
+
+ FileType
+ 1.0.0+
+ The FileType object
+
+
+ id
+ 1.0.0+
+ true
+ String
+
+
+ patterns
+ 1.0.0+
+ true
+
+ String
+ *
+
+
+
+
+
+ DatabaseScanningConfiguration
+ 1.0.0+
+
+ The scanning configuration for unprocessed ArchivaArtifact database objects.
+
+
+
+ cronExpression
+ 1.0.0+
+ String
+ When to run the database scanning mechanism. Default is every two hours on the hour.
+
+ 0 0 0/2 * * ?
+
+
+ unprocessedConsumers
+ 1.0.0+
+ true
+
+ String
+ *
+
+
+ The list of consumers for the unprocessed ArchivaArtifact database objects.
+
+
+
+ cleanupConsumers
+ 1.0.0+
+ true
+
+ String
+ *
+
+
+ The list of consumers for previously processed ArchivaArtifact database
+ objects that no longer exist on the filesystem, and might need to
+ undergo a cleanup.
+
+
+
+
+
+
+
+
+ OrganisationInformation
+ 1.1.0+
+
+ The organisation information settings.
+
+
+
+ name
+ name of the organisation
+ 1.1.0+
+
+ String
+
+
+
+ url
+ name of the organisation
+ 1.1.0+
+
+ String
+
+
+
+ logoLocation
+ name of the organisation
+ 1.1.0+
+
+ String
+
+
+
+
+
+
+ WebappConfiguration
+ 1.0.0+
+
+ The webapp configuration settings.
+
+
+
+ ui
+ options for altering the ui presentation
+ 1.0.0+
+
+ UserInterfaceOptions
+
+
+
+
+
+
+ UserInterfaceOptions
+ 1.0.0+
+
+ The user interface configuration settings.
+
+
+
+ showFindArtifacts
+ true if find artifacts should be enabled
+ 1.0.0+
+ boolean
+ true
+
+
+ appletFindEnabled
+ true if applet behavior for find artifacts should be enabled
+ 1.0.0+
+ boolean
+ true
+
+
+
+
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties
new file mode 100644
index 000000000..2beeea469
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+Key_properties=java.lang.String
+Element_properties=java.lang.String
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml
new file mode 100644
index 000000000..12473f3f1
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml
@@ -0,0 +1,178 @@
+
+
+ 2
+
+
+ internal
+ Archiva Managed Internal Repository
+ ${appserver.base}/data/repositories/internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+ 30
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ ${appserver.base}/data/repositories/snapshots
+ default
+ false
+ true
+ true
+ 0 0\,30 * * * ?
+ 30
+
+
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ http://download.java.net/maven/2/
+ default
+
+
+
+
+
+ internal
+ central
+
+
+ disabled
+ once
+ fix
+ cached
+
+
+ **/*
+
+
+
+ internal
+ maven2-repository.dev.java.net
+
+
+ disabled
+ once
+ fix
+ cached
+
+
+ javax/**
+ org/jvnet/**
+ com/sun/**
+
+
+
+
+
+
+ jaxen/jars/jaxen-1.0-FCS-full.jar
+ jaxen:jaxen:1.0-FCS:full:jar
+
+
+
+
+
+
+ artifacts
+
+ **/*.pom
+ **/*.jar
+ **/*.ear
+ **/*.war
+ **/*.car
+ **/*.sar
+ **/*.mar
+ **/*.rar
+ **/*.dtd
+ **/*.tld
+ **/*.tar.gz
+ **/*.tar.bz2
+ **/*.zip
+
+
+
+ indexable-content
+
+ **/*.txt
+ **/*.TXT
+ **/*.block
+ **/*.config
+ **/*.pom
+ **/*.xml
+ **/*.xsd
+ **/*.dtd
+ **/*.tld
+
+
+
+ auto-remove
+
+ **/*.bak
+ **/*~
+ **/*-
+
+
+
+ ignored
+
+ **/.htaccess
+ **/KEYS
+ **/*.rb
+ **/*.sh
+ **/.svn/**
+ **/.DAV/**
+
+
+
+
+ update-db-artifact
+ create-missing-checksums
+ update-db-repository-metadata
+ validate-checksum
+ validate-signature
+ index-content
+ auto-remove
+ auto-rename
+ metadata-updater
+
+
+
+ update-db-bad-content
+
+
+
+
+ 0 0 * * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ true
+ true
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-0.9.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-0.9.xml
new file mode 100644
index 000000000..c8032436a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-0.9.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ managed-repository
+ local
+ local
+
+
+
+
+ http://www.ibiblio.org/maven2/
+ local
+ true
+ ibiblio
+ Ibiblio
+
+
+ http://repository.codehaus.org/
+ local
+ codehaus
+ Codehaus
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-v1.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-v1.xml
new file mode 100644
index 000000000..2b05c9251
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-v1.xml
@@ -0,0 +1,191 @@
+
+
+
+
+
+
+ internal
+ Archiva Managed Internal Repository
+ file://${appserver.base}/repositories/internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ file://${appserver.base}/repositories/snapshots
+ default
+ false
+ true
+ false
+ 0 0,30 * * * ?
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+ true
+ false
+ false
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ https://maven2-repository.dev.java.net/nonav/repository
+ default
+ true
+ false
+ false
+
+
+
+
+
+ internal
+ central
+
+ disabled
+ never
+ not-found
+
+
+ internal
+ maven2-repository.dev.java.net
+
+ disabled
+ never
+ not-found
+
+ javax/**
+
+
+
+
+
+
+ example
+ http
+ proxy.mycompany.com
+ 8080
+ myself
+ mypass
+
+
+
+
+
+
+ artifacts
+
+ **/*.pom
+ **/*.jar
+ **/*.ear
+ **/*.war
+ **/*.car
+ **/*.sar
+ **/*.mar
+ **/*.rar
+ **/*.dtd
+ **/*.tld
+ **/*.tar.gz
+ **/*.tar.bz2
+ **/*.zip
+
+
+
+ indexable-content
+
+ **/*.txt
+ **/*.TXT
+ **/*.block
+ **/*.config
+ **/*.pom
+ **/*.xml
+ **/*.xsd
+ **/*.dtd
+ **/*.tld
+
+
+
+ auto-remove
+
+ **/*.bak
+ **/*~
+ **/*-
+
+
+
+ ignored
+
+ **/.htaccess
+ **/KEYS
+ **/*.rb
+ **/*.sh
+ **/.svn/**
+ **/.DAV/**
+
+
+
+
+ update-db-artifact
+ create-missing-checksums
+ update-db-repository-metadata
+ validate-checksum
+ validate-signature
+ index-content
+ auto-remove
+ auto-rename
+ metadata-updater
+
+
+
+ update-db-bad-content
+
+
+
+
+ 0 0 * * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ true
+ true
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml
new file mode 100644
index 000000000..29f3775bb
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+ internal
+ Archiva Managed Internal Repository
+ file://${appserver.base}/repositories/internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ file:${appserver.base}/repositories/snapshots
+ default
+ false
+ true
+ true
+ 0 0,30 * * * ?
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+ true
+ false
+ false
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ https://maven2-repository.dev.java.net/nonav/repository
+ default
+ true
+ false
+ false
+
+
+
+
+
+ internal
+ central
+
+ disabled
+ never
+ not-found
+
+
+ internal
+ maven2-repository.dev.java.net
+
+ disabled
+ never
+ not-found
+
+ javax/**
+
+
+
+
+
+
+ example
+ http
+ proxy.mycompany.com
+ 8080
+ myself
+ mypass
+
+
+
+
+
+
+ artifacts
+
+ **/*.pom
+ **/*.jar
+ **/*.ear
+ **/*.war
+ **/*.car
+ **/*.sar
+ **/*.mar
+ **/*.rar
+ **/*.dtd
+ **/*.tld
+ **/*.tar.gz
+ **/*.tar.bz2
+ **/*.zip
+
+
+
+ indexable-content
+
+ **/*.txt
+ **/*.TXT
+ **/*.block
+ **/*.config
+ **/*.pom
+ **/*.xml
+ **/*.xsd
+ **/*.dtd
+ **/*.tld
+
+
+
+ auto-remove
+
+ **/*.bak
+ **/*~
+ **/*-
+
+
+
+ ignored
+
+ **/.htaccess
+ **/KEYS
+ **/*.rb
+ **/*.sh
+ **/.svn/**
+ **/.DAV/**
+
+
+
+
+ update-db-artifact
+ create-missing-checksums
+ update-db-repository-metadata
+ validate-checksum
+ validate-signature
+ index-content
+ auto-remove
+ auto-rename
+ metadata-updater
+
+
+ update-db-bad-content
+
+
+
+
+ 0 0 * * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ true
+ true
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-base.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-base.xml
new file mode 100644
index 000000000..84ab085d0
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-base.xml
@@ -0,0 +1,65 @@
+
+
+
+
+ 2
+
+
+ internal
+ Archiva Managed Internal Repository
+ ${appserver.base}/repositories/internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ ${appserver.base}/repositories/snapshots
+ default
+ false
+ true
+ true
+ 0 0,30 * * * ?
+
+
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ https://maven2-repository.dev.java.net/nonav/repository
+ default
+
+
+
+
+
+ false
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-single-list-elements.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-single-list-elements.xml
new file mode 100644
index 000000000..3e3d4dc97
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-single-list-elements.xml
@@ -0,0 +1,97 @@
+
+
+
+
+ 2
+
+
+ default
+
+ snapshots
+
+
+
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ ${appserver.base}/repositories/snapshots
+ default
+ false
+ true
+ true
+ 0 0,30 * * * ?
+
+
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+
+
+
+
+ 2
+ internal
+ maven2-repository.dev.java.net
+
+
+ javax/**
+
+
+ once
+ fix
+ never
+ yes
+
+
+
+
+
+ proxy
+ proxy
+ 8080
+
+
+
+
+ jaxen/jars/jaxen-1.0-FCS-full.jar
+ jaxen:jaxen:1.0-FCS:full:jar
+
+
+
+
+ auto-remove
+
+
+ update-db-bad-content
+
+
+
+
+ update-db-bytecode-stats
+
+
+ not-present-remove-db-project
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-user.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-user.xml
new file mode 100644
index 000000000..61c4dadc2
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/conf-user.xml
@@ -0,0 +1,49 @@
+
+
+
+ 2
+
+
+ internal
+ central
+
+ disabled
+ never
+ not-found
+
+
+ internal
+ maven2-repository.dev.java.net
+
+ disabled
+ never
+ not-found
+
+ javax/**
+
+
+
+
+
+
+ false
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/corrupt.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/corrupt.xml
new file mode 100644
index 000000000..b4469289a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/corrupt.xml
@@ -0,0 +1,20 @@
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/escape-cron-expressions.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/escape-cron-expressions.xml
new file mode 100644
index 000000000..547e8c0b5
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/escape-cron-expressions.xml
@@ -0,0 +1,54 @@
+
+
+
+ 2
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ file://${appserver.base}/repositories/internal
+ false
+ true
+ 0 0\,30 * * * ?
+
+
+
+ 0 0 0 * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ false
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf
new file mode 100644
index 000000000..7908a9ad9
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf
@@ -0,0 +1,144 @@
+################ GLOBAL SETTINGS
+# This is where maven-proxy stores files it has downloaded
+repo.local.store=target
+
+#The port to listen on - not used if loaded as a webapp
+port=9999
+
+#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour
+#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using
+#a prefix.
+#The repository will be shown at http://localhost:9999/repository/
+#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change)
+# As maven doesn't like a trailing slash, this address shouldn't have one either.
+prefix=repository
+
+#This is the simple date format used to display the last modified date while browsing the repository.
+lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss
+
+################ SNAPSHOT HANDLING
+#If you want the proxy to look for newer snapshots, set to true
+snapshot.update=true
+
+################ M2 METADATA HANDLING
+#If you want the proxy to prevent looking for newer metadata, set to false (default is true)
+#metadata.update=false
+
+################ M2 POM HANDLING
+#If you want the proxy to look for newer POMs, set to true (default is false)
+pom.update=true
+
+################ PROMOTION HANDLING
+# ***** NOT CURRENTLY IMPLEMENTED *****
+#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It
+# is designed to be used by "higher security installations" that do not want to acquire artifacts from
+# remote repositories without approval.
+#
+#If promotion handling is enabled, then the proxy will not download remote artifacts without permission
+# (local repositories with copy=false are considered to be local)
+#
+#Permission to download is granted via the Promotion menu which will be enabled
+# when promotion handling is enabled.
+#
+#If promotion is false, artifacts are sourced from any repository as per normal.
+#
+#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using
+# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive.
+##
+promotion=false
+
+################ WEB INTERFACE
+# This defines the absolute URL the server should use to identify itself.
+# This can often be determined automatically, but we recommend you specify
+# it explicitly to prevent problems during startup.
+# The prefix will be added to this for the actual repository
+# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository
+serverName=http://localhost:9999
+
+#If true, the repository can be browsed
+browsable=true
+
+#If true, the repository can be searched
+searchable=true
+
+#Not currently implemented. Will allow webdav access to the repository at some point.
+webdav=true
+
+#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only
+#eg. /maven-proxy/style.css, http://www.example.com/style.css
+stylesheet=/maven-proxy/style.css
+
+#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
+#If a stylesheet is set, these are not used.
+bgColor=#14B
+bgColorHighlight=#94B
+
+#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
+#If a stylesheet is set, these are not used.
+rowColor=#CCF
+rowColorHighlight=#DDF
+
+
+################ PROXIES
+#This is just a hack, it should auto discover them
+proxy.list=one,two,three
+
+#Unauthenticated proxy
+proxy.one.host=proxy1.example.com
+proxy.one.port=3128
+
+#Authenticated proxy
+proxy.two.host=proxy2.example.org
+proxy.two.port=80
+proxy.two.username=username2
+proxy.two.password=password2
+
+#Authenticated proxy
+proxy.three.host=proxy3.example.net
+proxy.three.port=3129
+proxy.three.username=username3
+proxy.three.password=password3
+
+
+################# REPOSITORIES
+#This is not just a hack, it specifies the order repositories should be checked
+#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/"
+repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com
+
+#local-store
+# The local store represents a location that local jars you host can be located.
+# This could also be achieved by having a local http repository, but this is less cumbersome
+repo.local-repo.url=file://target
+repo.local-repo.description=Super Secret Custom Repository
+#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos
+repo.local-repo.copy=false
+#If hardfail is true, any unexpected errors from the repository will cause
+#the client download to fail (typically with a 500 error)
+repo.local-repo.hardfail=true
+#Don't cache a file repository
+repo.local-repo.cache.period=0
+
+
+#www.ibiblio.org
+repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2
+repo.www-ibiblio-org.description=www.ibiblio.org
+repo.www-ibiblio-org.proxy=one
+repo.www-ibiblio-org.hardfail=true
+#Cache this repository for 1 hour
+repo.www-ibiblio-org.cache.period=3600
+repo.www-ibiblio-org.cache.failures=true
+
+#dist.codehaus.org
+repo.dist-codehaus-org.url=http://dist.codehaus.org
+repo.dist-codehaus-org.proxy=two
+repo.dist-codehaus-org.hardfail=false
+repo.dist-codehaus-org.cache.period=3600
+repo.dist-codehaus-org.cache.failures=true
+
+#private.example.com
+repo.private-example-com.url=http://private.example.com/internal
+repo.private-example-com.description=Commercial In Confidence Repository
+repo.private-example-com.username=username1
+repo.private-example-com.password=password1
+repo.private-example-com.proxy=three
+repo.private-example-com.cache.period=3600
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml
new file mode 100644
index 000000000..8fabacf5b
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml
@@ -0,0 +1,193 @@
+
+
+
+
+ 2
+
+
+ internal
+ Archiva Managed Internal Repository
+ ${appserver.base}/repositories/internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ ${appserver.base}/repositories/internal
+ default
+ false
+ true
+ true
+ 0 0,30 * * * ?
+
+
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ https://maven2-repository.dev.java.net/nonav/repository
+ default
+
+
+
+
+
+
+
+ internal
+ central
+
+
+ ignored
+ disabled
+ cached
+
+
+
+ internal
+ maven2-repository.dev.java.net
+
+
+ ignored
+ disabled
+ cached
+
+
+ javax/**
+
+
+
+
+
+
+ example
+ http
+ proxy.mycompany.com
+ 8080
+ myself
+ mypass
+
+
+
+
+
+
+ artifacts
+
+ **/*.pom
+ **/*.jar
+ **/*.ear
+ **/*.war
+ **/*.car
+ **/*.sar
+ **/*.mar
+ **/*.rar
+ **/*.dtd
+ **/*.tld
+ **/*.tar.gz
+ **/*.tar.bz2
+ **/*.zip
+
+
+
+ indexable-content
+
+ **/*.txt
+ **/*.TXT
+ **/*.block
+ **/*.config
+ **/*.pom
+ **/*.xml
+ **/*.xsd
+ **/*.dtd
+ **/*.tld
+
+
+
+ auto-remove
+
+ **/*.bak
+ **/*~
+ **/*-
+
+
+
+ ignored
+
+ **/.htaccess
+ **/KEYS
+ **/*.rb
+ **/*.sh
+ **/.svn/**
+ **/.DAV/**
+
+
+
+
+ update-db-artifact
+ create-missing-checksums
+ update-db-repository-metadata
+ validate-checksum
+ validate-signature
+ index-content
+ auto-remove
+ auto-rename
+ metadata-updater
+
+
+ update-db-bad-content
+
+
+
+
+ 0 0 * * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ true
+ true
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
new file mode 100644
index 000000000..70c88d4d8
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
@@ -0,0 +1,819 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.easymock.MockControl;
+
+/**
+ * Test the configuration store.
+ *
+ * @author Brett Porter
+ */
+public class ArchivaConfigurationTest
+ extends PlexusInSpringTestCase
+{
+ /**
+ * {@inheritDoc}
+ * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getSpringConfigLocation()
+ */
+ protected String getSpringConfigLocation()
+ {
+ return "org/apache/maven/archiva/configuration/spring-context.xml";
+ }
+
+ public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
+ repository.getLocation() );
+ 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.isScanned() );
+ }
+
+ public void testGetConfigurationFromDefaults()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-defaults" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal",
+ repository.getLocation() );
+ 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.isScanned() );
+ }
+
+ // test for [MRM-789]
+ public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting()
+ throws Exception
+ {
+ File repo = new File( getBasedir(), "/target/test-classes/existing_snapshots" );
+ repo.mkdirs();
+
+ repo = new File( getBasedir(), "/target/test-classes/existing_internal" );
+ repo.mkdirs();
+
+ String existingTestDefaultArchivaConfigFile =
+ FileUtils.readFileToString( getTestFile( "target/test-classes/org/apache/maven/archiva/configuration/test-default-archiva.xml" ) ) ;
+ existingTestDefaultArchivaConfigFile = StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", getBasedir() );
+
+ File generatedTestDefaultArchivaConfigFile =
+ new File( getBasedir(), "target/test-classes/org/apache/maven/archiva/configuration/default-archiva.xml" );
+
+ FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile, null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(),
+ "test-defaults-default-repo-location-exists" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+ assertTrue( "check managed repositories", repository.getLocation().endsWith( "data/repositories/internal" ) );
+
+ generatedTestDefaultArchivaConfigFile.delete();
+ assertFalse( generatedTestDefaultArchivaConfigFile.exists() );
+ }
+
+ /**
+ * Ensures that the provided configuration matches the details present in the archiva-default.xml file.
+ */
+ private void assertConfiguration( Configuration configuration )
+ throws Exception
+ {
+ FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() );
+
+ assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() );
+ assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() );
+ assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
+
+ RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
+ assertNotNull( "check repository scanning", repoScanning );
+ assertEquals( "check file types", 4, repoScanning.getFileTypes().size() );
+ assertEquals( "check known consumers", 9, repoScanning.getKnownContentConsumers().size() );
+ assertEquals( "check invalid consumers", 1, repoScanning.getInvalidContentConsumers().size() );
+
+ List patterns = filetypes.getFileTypePatterns( "artifacts" );
+ assertNotNull( "check 'artifacts' file type", patterns );
+ assertEquals( "check 'artifacts' patterns", 13, patterns.size() );
+
+ DatabaseScanningConfiguration dbScanning = configuration.getDatabaseScanning();
+ assertNotNull( "check database scanning", dbScanning );
+ assertEquals( "check unprocessed consumers", 6, dbScanning.getUnprocessedConsumers().size() );
+ assertEquals( "check cleanup consumers", 3, dbScanning.getCleanupConsumers().size() );
+
+ WebappConfiguration webapp = configuration.getWebapp();
+ assertNotNull( "check webapp", webapp );
+
+ UserInterfaceOptions ui = webapp.getUi();
+ assertNotNull( "check webapp ui", ui );
+ assertTrue( "check showFindArtifacts", ui.isShowFindArtifacts() );
+ assertTrue( "check appletFindEnabled", ui.isAppletFindEnabled() );
+ }
+
+ public void testGetConfigurationFromRegistryWithTwoConfigurationResources()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration-both" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ // from base
+ assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() );
+ assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() );
+ // from user
+ assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
+
+ WebappConfiguration webapp = configuration.getWebapp();
+ assertNotNull( "check webapp", webapp );
+
+ UserInterfaceOptions ui = webapp.getUi();
+ assertNotNull( "check webapp ui", ui );
+ // from base
+ assertFalse( "check showFindArtifacts", ui.isShowFindArtifacts() );
+ // from user
+ assertFalse( "check appletFindEnabled", ui.isAppletFindEnabled() );
+ }
+
+ public void testGetConfigurationSystemOverride()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" );
+
+ System.setProperty( "org.apache.maven.archiva.webapp.ui.appletFindEnabled", "false" );
+
+ try
+ {
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ assertFalse( "check boolean", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+ finally
+ {
+ System.getProperties().remove( "org.apache.maven.archiva.webapp.ui.appletFindEnabled" );
+ }
+ }
+
+ public void testStoreConfiguration()
+ throws Exception
+ {
+ File file = getTestFile( "target/test/test-file.xml" );
+ file.delete();
+ assertFalse( file.exists() );
+
+ // TODO: remove with commons-configuration 1.4
+ file.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( file, "", null );
+
+ DefaultArchivaConfiguration archivaConfiguration =
+ (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" );
+
+ Configuration configuration = new Configuration();
+ configuration.setVersion( "1" );
+ configuration.setWebapp( new WebappConfiguration() );
+ configuration.getWebapp().setUi( new UserInterfaceOptions() );
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ // add a change listener
+ MockControl control = createConfigurationListenerMockControl();
+ ConfigurationListener listener = (ConfigurationListener) control.getMock();
+ archivaConfiguration.addListener( listener );
+
+ listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) );
+ control.setVoidCallable();
+
+ control.replay();
+
+ archivaConfiguration.save( configuration );
+
+ control.verify();
+
+ assertTrue( "Check file exists", file.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+
+ // read it back
+ archivaConfiguration =
+ (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" );
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+
+ private static MockControl createConfigurationListenerMockControl()
+ {
+ return MockControl.createControl( ConfigurationListener.class );
+ }
+
+ public void testStoreConfigurationUser()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( userFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = new Configuration();
+ configuration.setWebapp( new WebappConfiguration() );
+ configuration.getWebapp().setUi( new UserInterfaceOptions() );
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", userFile.exists() );
+ assertFalse( "Check file not created", baseFile.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+
+ public void testStoreConfigurationLoadedFromDefaults()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = new Configuration();
+ configuration.setWebapp( new WebappConfiguration() );
+ configuration.getWebapp().setUi( new UserInterfaceOptions() );
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ // add a change listener
+ MockControl control = createConfigurationListenerMockControl();
+ ConfigurationListener listener = (ConfigurationListener) control.getMock();
+ archivaConfiguration.addListener( listener );
+
+ listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) );
+ // once from default creation, and again from manual call to save
+ control.setVoidCallable( 2 );
+
+ control.replay();
+
+ archivaConfiguration.save( configuration );
+
+ control.verify();
+
+ assertTrue( "Check file exists", userFile.exists() );
+ assertFalse( "Check file not created", baseFile.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+
+ public void testDefaultUserConfigFilename()
+ throws Exception
+ {
+ DefaultArchivaConfiguration archivaConfiguration =
+ (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() );
+
+ assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml",
+ archivaConfiguration.getUserConfigFilename() );
+ assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml",
+ archivaConfiguration.getAltConfigFilename() );
+ }
+
+ public void testStoreConfigurationFallback()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( baseFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = new Configuration();
+ configuration.setWebapp( new WebappConfiguration() );
+ configuration.getWebapp().setUi( new UserInterfaceOptions() );
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", baseFile.exists() );
+ assertFalse( "Check file not created", userFile.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+
+ public void testStoreConfigurationFailsWhenReadFromBothLocationsNoLists()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( baseFile, "", null );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( userFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", baseFile.exists() );
+ assertEquals( "Check base file is unchanged", "",
+ FileUtils.readFileToString( baseFile, null ) );
+ assertTrue( "Check file exists", userFile.exists() );
+ assertFalse( "Check base file is changed",
+ "".equals( FileUtils.readFileToString( userFile, null ) ) );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+
+ public void testStoreConfigurationFailsWhenReadFromBothLocationsUserHasLists()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( baseFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertTrue( "check value", configuration.getWebapp().getUi().isShowFindArtifacts() );
+
+ configuration.getWebapp().getUi().setShowFindArtifacts( false );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", baseFile.exists() );
+ assertEquals( "Check base file is unchanged", "",
+ FileUtils.readFileToString( baseFile, null ) );
+ assertTrue( "Check file exists", userFile.exists() );
+ assertFalse( "Check base file is changed",
+ "".equals( FileUtils.readFileToString( userFile, null ) ) );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertFalse( "check value", configuration.getWebapp().getUi().isShowFindArtifacts() );
+ }
+
+ public void testStoreConfigurationFailsWhenReadFromBothLocationsAppserverHasLists()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( userFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+
+ configuration.getWebapp().getUi().setAppletFindEnabled( false );
+
+ try
+ {
+ archivaConfiguration.save( configuration );
+ fail( "Configuration saving should not succeed if it was loaded from two locations" );
+ }
+ catch ( IndeterminateConfigurationException e )
+ {
+ // check it was reverted
+ configuration = archivaConfiguration.getConfiguration();
+ assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+ }
+ }
+
+ public void testLoadConfigurationFromInvalidBothLocationsOnDisk()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-not-allowed-to-write-to-both" );
+ Configuration config = archivaConfiguration.getConfiguration();
+
+ try
+ {
+ archivaConfiguration.save( config );
+ fail( "Should have thrown a RegistryException because the configuration can't be saved." );
+ }
+ catch ( RegistryException e )
+ {
+ /* expected exception */
+ }
+ }
+
+ public void testLoadConfigurationFromInvalidUserLocationOnDisk()
+ throws Exception
+ {
+ File testConfDir = getTestFile( "target/test-appserver-base/conf/" );
+ testConfDir.mkdirs();
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-not-allowed-to-write-to-user" );
+ Configuration config = archivaConfiguration.getConfiguration();
+ archivaConfiguration.save( config );
+ // No Exception == test passes.
+ // Expected Path is: Should not have thrown an exception.
+ }
+
+ public void testConfigurationUpgradeFrom09()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-upgrade-09" );
+
+ // we just use the defaults when upgrading from 0.9 at this point.
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal",
+ repository.getLocation() );
+ 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.isScanned() );
+ }
+
+ public void testAutoDetectV1()
+ throws Exception
+ {
+ // Setup the autodetect-v1.xml file in the target directory (so we can save/load it)
+ File userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ), userFile );
+
+ // Load the original (unconverted) archiva.xml
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
+ repository.getLocation() );
+ 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.isScanned() );
+
+ // Test that only 1 set of repositories exist.
+ assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
+ assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
+ assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
+
+ // Save the file.
+ archivaConfiguration.save( configuration );
+
+ // Release existing
+// FIXME spring equivalent ? release( archivaConfiguration );
+
+ // Reload.
+ archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" );
+ configuration = archivaConfiguration.getConfiguration();
+
+ // Test that only 1 set of repositories exist.
+ assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
+ assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() );
+ assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
+ assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() );
+ assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
+
+ String actualXML = FileUtils.readFileToString( userFile, null );
+ XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML );
+ XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML );
+ }
+
+ public void testArchivaV1()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-archiva-v1" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
+
+ assertEquals( "check managed repositories", 2, configuration.getManagedRepositories().size() );
+ assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
+
+ Map map = configuration.getManagedRepositoriesAsMap();
+
+ ManagedRepositoryConfiguration repository = map.get( "internal" );
+ assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
+ repository.getLocation() );
+ 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.isScanned() );
+ assertFalse( "check managed repositories", repository.isSnapshots() );
+
+ repository = map.get( "snapshots" );
+ assertEquals( "check managed repositories", "${appserver.base}/repositories/snapshots",
+ repository.getLocation() );
+ assertEquals( "check managed repositories", "Archiva Managed Snapshot Repository", repository.getName() );
+ assertEquals( "check managed repositories", "snapshots", repository.getId() );
+ assertEquals( "check managed repositories", "default", repository.getLayout() );
+ assertFalse( "check managed repositories", repository.isScanned() );
+ assertTrue( "check managed repositories", repository.isSnapshots() );
+ }
+
+ public void testCronExpressionsWithComma()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.copyFile( getTestFile( "src/test/conf/escape-cron-expressions.xml" ), baseFile );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( userFile, "", null );
+
+ final ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-cron-expressions" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check cron expression", "0 0,30 * * * ?", repository.getRefreshCronExpression().trim() );
+
+ configuration.getDatabaseScanning().setCronExpression( "0 0,15 0 * * ?" );
+
+ // add a test listener to confirm it doesn't see the escaped format. We don't need to test the number of calls,
+ // etc. as it's done in other tests
+ archivaConfiguration.addListener( new ConfigurationListener()
+ {
+ public void configurationEvent( ConfigurationEvent event )
+ {
+ assertEquals( ConfigurationEvent.SAVED, event.getType() );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ ManagedRepositoryConfiguration repository =
+ (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+
+ assertEquals( "check cron expression", "0 0,15 0 * * ?",
+ configuration.getDatabaseScanning().getCronExpression() );
+ }
+ } );
+
+ archivaConfiguration.save( configuration );
+
+ configuration = archivaConfiguration.getConfiguration();
+
+ assertEquals( "check cron expression", "0 0,15 0 * * ?",
+ configuration.getDatabaseScanning().getCronExpression() );
+
+ // test for the escape character '\' showing up on repositories.jsp
+ repository.setRefreshCronExpression( "0 0,20 0 * * ?" );
+
+ archivaConfiguration.save( configuration );
+
+ repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( "snapshots" );
+
+ assertEquals( "check cron expression", "0 0,20 0 * * ?", repository.getRefreshCronExpression() );
+ }
+
+ public void testRemoveLastElements()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ baseFile.getParentFile().mkdirs();
+ FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( userFile, "", null );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-central" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ RepositoryGroupConfiguration repositoryGroup = ( RepositoryGroupConfiguration ) configuration.getRepositoryGroups().get( 0 );
+ assertNotNull( repositoryGroup );
+ configuration.removeRepositoryGroup( repositoryGroup );
+ assertTrue( configuration.getRepositoryGroups().isEmpty() );
+
+ RemoteRepositoryConfiguration repository = configuration.getRemoteRepositoriesAsMap().get( "central" );
+ assertNotNull( repository );
+ configuration.removeRemoteRepository( repository );
+ assertTrue( configuration.getRemoteRepositories().isEmpty() );
+
+ ManagedRepositoryConfiguration managedRepository =
+ configuration.getManagedRepositoriesAsMap().get( "snapshots" );
+ assertNotNull( managedRepository );
+ configuration.removeManagedRepository( managedRepository );
+ assertTrue( configuration.getManagedRepositories().isEmpty() );
+
+ ProxyConnectorConfiguration proxyConnector =
+ (ProxyConnectorConfiguration) configuration.getProxyConnectors().get( 0 );
+ assertNotNull( proxyConnector );
+ configuration.removeProxyConnector( proxyConnector );
+ assertTrue( configuration.getProxyConnectors().isEmpty() );
+
+ NetworkProxyConfiguration networkProxy = configuration.getNetworkProxiesAsMap().get( "proxy" );
+ assertNotNull( networkProxy );
+ configuration.removeNetworkProxy( networkProxy );
+ assertTrue( configuration.getNetworkProxies().isEmpty() );
+
+ LegacyArtifactPath path = (LegacyArtifactPath) configuration.getLegacyArtifactPaths().get( 0 );
+ assertNotNull( path );
+ configuration.removeLegacyArtifactPath( path );
+ assertTrue( configuration.getLegacyArtifactPaths().isEmpty() );
+
+ RepositoryScanningConfiguration scanning = configuration.getRepositoryScanning();
+ String consumer = (String) scanning.getKnownContentConsumers().get( 0 );
+ assertNotNull( consumer );
+ scanning.removeKnownContentConsumer( consumer );
+ assertTrue( scanning.getKnownContentConsumers().isEmpty() );
+ consumer = (String) scanning.getInvalidContentConsumers().get( 0 );
+ assertNotNull( consumer );
+ scanning.removeInvalidContentConsumer( consumer );
+ assertTrue( scanning.getInvalidContentConsumers().isEmpty() );
+
+ DatabaseScanningConfiguration databaseScanning = configuration.getDatabaseScanning();
+ consumer = (String) databaseScanning.getCleanupConsumers().get( 0 );
+ assertNotNull( consumer );
+ databaseScanning.removeCleanupConsumer( consumer );
+ assertTrue( databaseScanning.getCleanupConsumers().isEmpty() );
+ consumer = (String) databaseScanning.getUnprocessedConsumers().get( 0 );
+ assertNotNull( consumer );
+ databaseScanning.removeUnprocessedConsumer( consumer );
+ assertTrue( databaseScanning.getUnprocessedConsumers().isEmpty() );
+
+ archivaConfiguration.save( configuration );
+
+ archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" );
+ configuration = archivaConfiguration.getConfiguration();
+ assertNull( configuration.getRemoteRepositoriesAsMap().get( "central" ) );
+ assertTrue( configuration.getRepositoryGroups().isEmpty() );
+ assertNull( configuration.getManagedRepositoriesAsMap().get( "snapshots" ) );
+ assertTrue( configuration.getProxyConnectors().isEmpty() );
+ assertNull( configuration.getNetworkProxiesAsMap().get( "proxy" ) );
+ assertTrue( configuration.getLegacyArtifactPaths().isEmpty() );
+ scanning = configuration.getRepositoryScanning();
+ assertTrue( scanning.getKnownContentConsumers().isEmpty() );
+ assertTrue( scanning.getInvalidContentConsumers().isEmpty() );
+ databaseScanning = configuration.getDatabaseScanning();
+ assertTrue( databaseScanning.getCleanupConsumers().isEmpty() );
+ assertTrue( databaseScanning.getUnprocessedConsumers().isEmpty() );
+ }
+
+ /**
+ * [MRM-582] Remote Repositories with empty and fields shouldn't be created in configuration.
+ */
+ public void testGetConfigurationFixEmptyRemoteRepoUsernamePassword()
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup(
+ ArchivaConfiguration.class.getName(),
+ "test-configuration" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ assertConfiguration( configuration );
+ assertEquals( "check remote repositories", 2, configuration.getRemoteRepositories().size() );
+
+ RemoteRepositoryConfiguration repository = (RemoteRepositoryConfiguration) configuration
+ .getRemoteRepositoriesAsMap().get( "maven2-repository.dev.java.net" );
+
+ assertEquals( "remote repository.url", "https://maven2-repository.dev.java.net/nonav/repository", repository.getUrl() );
+ assertEquals( "remote repository.name", "Java.net Repository for Maven 2", repository.getName() );
+ assertEquals( "remote repository.id", "maven2-repository.dev.java.net", repository.getId() );
+ assertEquals( "remote repository.layout", "default", repository.getLayout() );
+ assertNull( "remote repository.username == null", repository.getUsername() );
+ assertNull( "remote repository.password == null", repository.getPassword() );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ConfigurationTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ConfigurationTest.java
new file mode 100644
index 000000000..fa6699766
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ConfigurationTest.java
@@ -0,0 +1,144 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * Test the generated Configuration class from Modello. This is primarily to test the hand coded methods.
+ */
+public class ConfigurationTest
+ extends TestCase
+{
+ private Configuration configuration = new Configuration();
+
+ public void testNetworkProxyRetrieval()
+ {
+ NetworkProxyConfiguration proxy1 = createNetworkProxy( "id1", "host1", 8080 );
+ configuration.addNetworkProxy( proxy1 );
+ NetworkProxyConfiguration proxy2 = createNetworkProxy( "id2", "host2", 9090 );
+ configuration.addNetworkProxy( proxy2 );
+
+ Map map = configuration.getNetworkProxiesAsMap();
+ assertNotNull( map );
+ assertEquals( 2, map.size() );
+ assertEquals( new HashSet( Arrays.asList( "id1", "id2" ) ), map.keySet() );
+ assertEquals( new HashSet( Arrays.asList( proxy1, proxy2 ) ),
+ new HashSet( map.values() ) );
+ }
+
+ private NetworkProxyConfiguration createNetworkProxy( String id, String host, int port )
+ {
+ NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
+ proxy.setId( id );
+ proxy.setHost( host );
+ proxy.setPort( port );
+ proxy.setProtocol( "http" );
+ return proxy;
+ }
+
+ public void testRemoteRepositoryRetrieval()
+ {
+ RemoteRepositoryConfiguration repo1 = createRemoteRepository( "id1", "name 1", "url 1" );
+ configuration.addRemoteRepository( repo1 );
+ RemoteRepositoryConfiguration repo2 = createRemoteRepository( "id2", "name 2", "url 2" );
+ configuration.addRemoteRepository( repo2 );
+
+ Map map = configuration.getRemoteRepositoriesAsMap();
+ assertNotNull( map );
+ assertEquals( 2, map.size() );
+ assertEquals( new HashSet( Arrays.asList( "id1", "id2" ) ), map.keySet() );
+ assertEquals( new HashSet( Arrays.asList( repo1, repo2 ) ),
+ new HashSet( map.values() ) );
+
+ assertEquals( repo1, configuration.findRemoteRepositoryById( "id1" ) );
+ assertEquals( repo2, configuration.findRemoteRepositoryById( "id2" ) );
+ assertNull( configuration.findRemoteRepositoryById( "id3" ) );
+ }
+
+ private RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
+ {
+ RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLayout( "default" );
+ repo.setUrl( url );
+ return repo;
+ }
+
+ public void testManagedRepositoryRetrieval()
+ {
+ ManagedRepositoryConfiguration repo1 = createManagedRepository( "id1", "name 1", "path 1", false );
+ configuration.addManagedRepository( repo1 );
+ ManagedRepositoryConfiguration repo2 = createManagedRepository( "id2", "name 2", "path 2", true );
+ configuration.addManagedRepository( repo2 );
+
+ Map map = configuration.getManagedRepositoriesAsMap();
+ assertNotNull( map );
+ assertEquals( 2, map.size() );
+ assertEquals( new HashSet( Arrays.asList( "id1", "id2" ) ), map.keySet() );
+ assertEquals( new HashSet( Arrays.asList( repo1, repo2 ) ),
+ new HashSet( map.values() ) );
+
+ assertEquals( repo1, configuration.findManagedRepositoryById( "id1" ) );
+ assertEquals( repo2, configuration.findManagedRepositoryById( "id2" ) );
+ assertNull( configuration.findManagedRepositoryById( "id3" ) );
+ }
+
+ private ManagedRepositoryConfiguration createManagedRepository( String id, String name, String location,
+ boolean scanned )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLocation( location );
+ repo.setScanned( scanned );
+ return repo;
+ }
+
+ public void testNetworkProxyRetrievalWhenEmpty()
+ {
+ Map map = configuration.getNetworkProxiesAsMap();
+ assertNotNull( map );
+ assertTrue( map.isEmpty() );
+ }
+
+ public void testRemoteRepositoryRetrievalWhenEmpty()
+ {
+ Map map = configuration.getRemoteRepositoriesAsMap();
+ assertNotNull( map );
+ assertTrue( map.isEmpty() );
+
+ assertNull( configuration.findRemoteRepositoryById( "id" ) );
+ }
+
+ public void testManagedRepositoryRetrievalWhenEmpty()
+ {
+ Map map = configuration.getManagedRepositoriesAsMap();
+ assertNotNull( map );
+ assertTrue( map.isEmpty() );
+
+ assertNull( configuration.findManagedRepositoryById( "id" ) );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java
new file mode 100644
index 000000000..6c5df3bf8
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+public class FileTypesTest
+ extends PlexusInSpringTestCase
+{
+ private FileTypes filetypes;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ filetypes = (FileTypes) lookup( FileTypes.class );
+ }
+
+ public void testIsArtifact()
+ {
+ assertTrue( filetypes.matchesArtifactPattern( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
+ assertTrue( filetypes.matchesArtifactPattern(
+ "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
+ assertTrue( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
+
+ assertFalse(
+ filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
+ assertFalse(
+ filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
+ assertFalse(
+ filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
+ assertFalse(
+ filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
+ assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
+ assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/maven-metadata.xml" ) );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java
new file mode 100644
index 000000000..dfeba0527
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/LegacyArtifactPathTest.java
@@ -0,0 +1,56 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * Test the generated LegacyArtifactPath class from Modello. This is primarily to test the hand coded methods.
+ * @since 1.1
+ */
+public class LegacyArtifactPathTest
+ extends TestCase
+{
+
+ private LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
+
+ public void testLegacyArtifactPathWithClassifierResolution()
+ {
+ legacyArtifactPath.setArtifact( "groupId:artifactId:version:classifier:type" );
+
+ assertEquals( "groupId", legacyArtifactPath.getGroupId() );
+ assertEquals( "artifactId", legacyArtifactPath.getArtifactId() );
+ assertEquals( "version", legacyArtifactPath.getVersion() );
+ assertEquals( "classifier", legacyArtifactPath.getClassifier() );
+ assertEquals( "type", legacyArtifactPath.getType() );
+ }
+
+
+ public void testLegacyArtifactPathWithoutClassifierResolution()
+ {
+ legacyArtifactPath.setArtifact( "groupId:artifactId:version::type" );
+
+ assertEquals( "groupId", legacyArtifactPath.getGroupId() );
+ assertEquals( "artifactId", legacyArtifactPath.getArtifactId() );
+ assertEquals( "version", legacyArtifactPath.getVersion() );
+ assertNull( legacyArtifactPath.getClassifier() );
+ assertEquals( "type", legacyArtifactPath.getType() );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java
new file mode 100644
index 000000000..f472b6564
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java
@@ -0,0 +1,108 @@
+package org.apache.maven.archiva.configuration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class MavenProxyPropertyLoaderTest
+ extends PlexusInSpringTestCase
+{
+ private MavenProxyPropertyLoader loader;
+
+ /**
+ * {@inheritDoc}
+ * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getSpringConfigLocation()
+ */
+ protected String getSpringConfigLocation()
+ {
+ return "org/apache/maven/archiva/configuration/spring-context.xml";
+ }
+
+ public void testLoadValidMavenProxyConfiguration()
+ throws IOException, InvalidConfigurationException
+ {
+ File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
+
+ Configuration configuration = new Configuration();
+ NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
+ proxy.setHost( "original-host" );
+ configuration.addNetworkProxy( proxy ); // overwritten
+
+ loader.load( new FileInputStream( confFile ), configuration );
+
+ Map repositoryIdMap = configuration.getManagedRepositoriesAsMap();
+ assertEquals( "Count repositories", 1, repositoryIdMap.size() );
+ assertRepositoryExists( "maven-proxy", "target", repositoryIdMap.get( "maven-proxy" ) );
+
+ Map remoteRepositoryMap = configuration.getRemoteRepositoriesAsMap();
+ assertEquals( "Count repositories", 4, remoteRepositoryMap.size() );
+ assertRepositoryExists( "local-repo", "file://target", remoteRepositoryMap.get( "local-repo" ) );
+ assertRepositoryExists( "www-ibiblio-org", "http://www.ibiblio.org/maven2",
+ remoteRepositoryMap.get( "www-ibiblio-org" ) );
+ assertRepositoryExists( "dist-codehaus-org", "http://dist.codehaus.org",
+ remoteRepositoryMap.get( "dist-codehaus-org" ) );
+ assertRepositoryExists( "private-example-com", "http://private.example.com/internal",
+ remoteRepositoryMap.get( "private-example-com" ) );
+ }
+
+ private void assertRepositoryExists( String id, String expectedLocation, ManagedRepositoryConfiguration repo )
+ {
+ assertNotNull( "Repository id [" + id + "] should not be null", repo );
+ assertEquals( "Repository id", id, repo.getId() );
+ assertEquals( "Repository url", expectedLocation, repo.getLocation() );
+ }
+
+ private void assertRepositoryExists( String id, String expectedUrl, RemoteRepositoryConfiguration repo )
+ {
+ assertNotNull( "Repository id [" + id + "] should not be null", repo );
+ assertEquals( "Repository id", id, repo.getId() );
+ assertEquals( "Repository url", expectedUrl, repo.getUrl() );
+ }
+
+ public void testInvalidConfiguration()
+ {
+ Configuration configuration = new Configuration();
+ try
+ {
+ loader.load( new Properties(), configuration );
+ fail( "Incomplete config should have failed" );
+ }
+ catch ( InvalidConfigurationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ loader = new MavenProxyPropertyLoader();
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java
new file mode 100644
index 000000000..9d1552b6a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparatorTest.java
@@ -0,0 +1,131 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * ProxyConnectorConfigurationOrderComparatorTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ProxyConnectorConfigurationOrderComparatorTest
+ extends TestCase
+{
+ public void testSortOfAllZeros()
+ {
+ List proxies = new ArrayList();
+
+ proxies.add( createConnector( "corporate", 0 ) );
+ proxies.add( createConnector( "snapshots", 0 ) );
+ proxies.add( createConnector( "3rdparty", 0 ) );
+ proxies.add( createConnector( "sandbox", 0 ) );
+
+ Collections.sort( proxies, ProxyConnectorConfigurationOrderComparator.getInstance() );
+
+ assertProxyOrder( new String[] { "corporate", "snapshots", "3rdparty", "sandbox" }, proxies );
+ }
+
+ public void testSortNormal()
+ {
+ List proxies = new ArrayList();
+
+ proxies.add( createConnector( "corporate", 3 ) );
+ proxies.add( createConnector( "snapshots", 1 ) );
+ proxies.add( createConnector( "3rdparty", 2 ) );
+ proxies.add( createConnector( "sandbox", 4 ) );
+
+ Collections.sort( proxies, new ProxyConnectorConfigurationOrderComparator() );
+
+ assertProxyOrder( new String[] { "snapshots", "3rdparty", "corporate", "sandbox" }, proxies );
+ }
+
+ public void testSortPartial()
+ {
+ List proxies = new ArrayList();
+
+ proxies.add( createConnector( "corporate", 3 ) );
+ proxies.add( createConnector( "snapshots", 0 ) );
+ proxies.add( createConnector( "3rdparty", 2 ) );
+ proxies.add( createConnector( "sandbox", 0 ) );
+
+ Collections.sort( proxies, new ProxyConnectorConfigurationOrderComparator() );
+
+ assertProxyOrder( new String[] { "3rdparty", "corporate", "snapshots", "sandbox" }, proxies );
+ }
+
+ private void assertProxyOrder( String[] ids, List proxies )
+ {
+ assertEquals( "Proxies.size() == ids.length", ids.length, proxies.size() );
+
+ int orderFailedAt = -1;
+
+ for ( int i = 0; i < ids.length; i++ )
+ {
+ if ( !StringUtils.equals( ids[i], proxies.get( i ).getProxyId() ) )
+ {
+ orderFailedAt = i;
+ break;
+ }
+ }
+
+ if ( orderFailedAt >= 0 )
+ {
+ StringBuffer msg = new StringBuffer();
+
+ msg.append( "Failed expected order of the proxies <" );
+ msg.append( StringUtils.join( ids, ", " ) );
+ msg.append( ">, actual <" );
+
+ boolean needsComma = false;
+ for ( ProxyConnectorConfiguration proxy : proxies )
+ {
+ if ( needsComma )
+ {
+ msg.append( ", " );
+ }
+ msg.append( proxy.getProxyId() );
+ needsComma = true;
+ }
+ msg.append( "> failure at index <" ).append( orderFailedAt ).append( ">." );
+
+ fail( msg.toString() );
+ }
+ }
+
+ private ProxyConnectorConfiguration createConnector( String id, int order )
+ {
+ ProxyConnectorConfiguration proxy = new ProxyConnectorConfiguration();
+ proxy.setProxyId( id );
+ proxy.setOrder( order );
+ proxy.setSourceRepoId( id + "_m" );
+ proxy.setTargetRepoId( id + "_r" );
+
+ return proxy;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparatorTest.java b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparatorTest.java
new file mode 100644
index 000000000..3dd314842
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/functors/RepositoryConfigurationComparatorTest.java
@@ -0,0 +1,52 @@
+package org.apache.maven.archiva.configuration.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+
+import java.util.Comparator;
+
+/**
+ * Test the repositry comparator.
+ */
+public class RepositoryConfigurationComparatorTest
+ extends TestCase
+{
+ public void testComparator()
+ {
+ Comparator comparator = new RepositoryConfigurationComparator();
+
+ assertEquals( 0, comparator.compare( null, null ) );
+ assertEquals( 1, comparator.compare( createRepository( "id" ), null ) );
+ assertEquals( -1, comparator.compare( null, createRepository( "id" ) ) );
+ assertEquals( 0, comparator.compare( createRepository( "id1" ), createRepository( "id1" ) ) );
+ assertEquals( -1, comparator.compare( createRepository( "id1" ), createRepository( "id2" ) ) );
+ assertEquals( 1, comparator.compare( createRepository( "id2" ), createRepository( "id1" ) ) );
+ }
+
+ private ManagedRepositoryConfiguration createRepository( String id )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ return repo;
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/log4j.properties b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/log4j.properties
new file mode 100644
index 000000000..6d107570b
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/log4j.properties
@@ -0,0 +1,10 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=INFO, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml
new file mode 100644
index 000000000..0e84402c7
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml
@@ -0,0 +1,495 @@
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-defaults-default-repo-location-exists
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ empty
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-defaults
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ empty
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ empty
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-upgrade-09
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ upgrade-09
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ upgrade-09
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-configuration
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ configured
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ configured
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-autodetect-v1
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ autodetect-v1
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ autodetect-v1
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-archiva-v1
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ archiva-v1
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ archiva-v1
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-save
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ save
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ save
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-save-user
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ save-user
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/test/test-file-user.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ save-user
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-configuration-both
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ configuration-both
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ configuration-both
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-read-saved
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ read-saved
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/test/test-file.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ read-saved
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-cron-expressions
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ cron-expressions
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/test/test-file.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ cron-expressions
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-remove-central
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ remove-central
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/test/test-file.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ remove-central
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-not-allowed-to-write-to-both
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ not-allowed-to-write-to-both
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/*intentionally:invalid*/.m2/archiva-user.xml
+ ${basedir}/target/*intentionally:invalid*/conf/archiva.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ not-allowed-to-write-to-both
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ test-not-allowed-to-write-to-user
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ not-allowed-to-write-to-user
+
+
+ org.apache.maven.archiva.policies.PreDownloadPolicy
+ prePolicies
+
+
+ org.apache.maven.archiva.policies.PostDownloadPolicy
+ postPolicies
+
+
+
+ ${basedir}/target/*intentionally:invalid*/.m2/archiva-user.xml
+ ${basedir}/target/test-appserver-base/conf/archiva.xml
+
+
+
+ org.codehaus.plexus.registry.Registry
+ not-allowed-to-write-to-user
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+
+
+ org.codehaus.plexus.cache.Cache
+ url-failures-cache
+ org.codehaus.plexus.cache.ehcache.EhcacheCache
+ URL Failure Cache
+
+ 600
+ false
+ false
+ 1000
+ LRU
+ cache
+ false
+
+ 2700
+
+ 1800
+
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/test-default-archiva.xml b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/test-default-archiva.xml
new file mode 100644
index 000000000..6f44eb4af
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/test-default-archiva.xml
@@ -0,0 +1,176 @@
+
+ 2
+
+
+ internal
+ Archiva Managed Internal Repository
+ ${appserver.base}/target/test-classes/existing_internal
+ default
+ true
+ false
+ true
+ 0 0 * * * ?
+ 30
+
+
+ snapshots
+ Archiva Managed Snapshot Repository
+ ${appserver.base}/target/test-classes/existing_snapshots
+ default
+ false
+ true
+ true
+ 0 0\,30 * * * ?
+ 30
+
+
+
+
+ central
+ Central Repository
+ http://repo1.maven.org/maven2
+ default
+
+
+ maven2-repository.dev.java.net
+ Java.net Repository for Maven 2
+ http://download.java.net/maven/2/
+ default
+
+
+
+
+
+ internal
+ central
+
+
+ disabled
+ once
+ fix
+ cached
+
+
+ **/*
+
+
+
+ internal
+ maven2-repository.dev.java.net
+
+
+ disabled
+ once
+ fix
+ cached
+
+
+ javax/**
+ org/jvnet/**
+ com/sun/**
+
+
+
+
+
+
+ jaxen/jars/jaxen-1.0-FCS-full.jar
+ jaxen:jaxen:1.0-FCS:full:jar
+
+
+
+
+
+
+ artifacts
+
+ **/*.pom
+ **/*.jar
+ **/*.ear
+ **/*.war
+ **/*.car
+ **/*.sar
+ **/*.mar
+ **/*.rar
+ **/*.dtd
+ **/*.tld
+ **/*.tar.gz
+ **/*.tar.bz2
+ **/*.zip
+
+
+
+ indexable-content
+
+ **/*.txt
+ **/*.TXT
+ **/*.block
+ **/*.config
+ **/*.pom
+ **/*.xml
+ **/*.xsd
+ **/*.dtd
+ **/*.tld
+
+
+
+ auto-remove
+
+ **/*.bak
+ **/*~
+ **/*-
+
+
+
+ ignored
+
+ **/.htaccess
+ **/KEYS
+ **/*.rb
+ **/*.sh
+ **/.svn/**
+ **/.DAV/**
+
+
+
+
+ update-db-artifact
+ create-missing-checksums
+ update-db-repository-metadata
+ validate-checksum
+ validate-signature
+ index-content
+ auto-remove
+ auto-rename
+ metadata-updater
+
+
+
+ update-db-bad-content
+
+
+
+
+ 0 0 * * * ?
+
+ index-artifact
+ update-db-project
+ validate-repository-metadata
+ index-archive-toc
+ update-db-bytecode-stats
+ index-public-methods
+
+
+ not-present-remove-db-artifact
+ not-present-remove-db-project
+ not-present-remove-indexed
+
+
+
+
+
+ true
+ true
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
new file mode 100644
index 000000000..c33620442
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.archiva
+ archiva-consumers
+ 1.2-SNAPSHOT
+ ../pom.xml
+
+
+ archiva-consumer-api
+ Archiva Consumer API
+ jar
+
+
+
+ org.apache.archiva
+ archiva-configuration
+
+
+ org.apache.archiva
+ archiva-model
+
+
+ commons-collections
+ commons-collections
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
new file mode 100644
index 000000000..7c306e1e0
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
@@ -0,0 +1,109 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.archiva.configuration.FileTypes;
+
+/**
+ * AbstractMonitoredConsumer
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public abstract class AbstractMonitoredConsumer
+ implements BaseConsumer
+{
+ private Set monitors = new HashSet();
+
+ public void addConsumerMonitor( ConsumerMonitor monitor )
+ {
+ monitors.add( monitor );
+ }
+
+ public void removeConsumerMonitor( ConsumerMonitor monitor )
+ {
+ monitors.remove( monitor );
+ }
+
+ protected void triggerConsumerError( String type, String message )
+ {
+ for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+ {
+ ConsumerMonitor monitor = itmonitors.next();
+ try
+ {
+ monitor.consumerError( this, type, message );
+ }
+ catch ( Throwable t )
+ {
+ /* discard error */
+ }
+ }
+ }
+
+ protected void triggerConsumerWarning( String type, String message )
+ {
+ for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+ {
+ ConsumerMonitor monitor = itmonitors.next();
+ try
+ {
+ monitor.consumerWarning( this, type, message );
+ }
+ catch ( Throwable t )
+ {
+ /* discard error */
+ }
+ }
+ }
+
+ protected void triggerConsumerInfo( String message )
+ {
+ for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+ {
+ ConsumerMonitor monitor = itmonitors.next();
+ try
+ {
+ monitor.consumerInfo( this, message );
+ }
+ catch ( Throwable t )
+ {
+ /* discard error */
+ }
+ }
+ }
+
+ public boolean isProcessUnmodified()
+ {
+ return false;
+ }
+
+ protected List getDefaultArtifactExclusions()
+ {
+ return FileTypes.DEFAULT_EXCLUSIONS;
+ }
+
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
new file mode 100644
index 000000000..209051742
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
@@ -0,0 +1,81 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.List;
+
+/**
+ * ArchivaArtifactConsumer - consumer for ArchivaArtifact objects.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface ArchivaArtifactConsumer extends BaseConsumer
+{
+ /**
+ * Get the list of included file patterns for this consumer.
+ *
+ * @return the list of ({@link String}) artifact types to process.
+ */
+ public List getIncludedTypes();
+
+ /**
+ *
+ * Event that triggers at the beginning of a scan.
+ *
+ *
+ *
+ * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
+ * generally start tracking the scan as a whole.
+ *
+ */
+ public void beginScan();
+
+ /**
+ *
+ * Event indicating an {@link ArchivaArtifact} is to be processed by this consumer.
+ *
+ *
+ *
+ * NOTE: The consumer does not need to process the artifact immediately, can can opt to queue and/or track
+ * the artifact to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
+ * event.
+ *
+ *
+ * @param file the file to process.
+ * @throws ConsumerException if there was a problem processing this file.
+ */
+ public void processArchivaArtifact( ArchivaArtifact artifact ) throws ConsumerException;
+
+ /**
+ *
+ * Event that triggers on the completion of a scan.
+ *
+ *
+ *
+ * NOTE: If the consumer opted to batch up processing requests in the
+ * {@link #processArchivaArtifact(ArchivaArtifact)} event this would be the last opportunity to drain
+ * any processing queue's.
+ *
+ */
+ public void completeScan();
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
new file mode 100644
index 000000000..2f32f1fec
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
@@ -0,0 +1,64 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * BaseConsumer - the base set of methods for a consumer.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public abstract interface BaseConsumer
+{
+ /**
+ * This is the id for the consumer.
+ *
+ * @return the consumer id.
+ */
+ public String getId();
+
+ /**
+ * The human readable description for this consumer.
+ *
+ * @return the human readable description for this consumer.
+ */
+ public String getDescription();
+
+ /**
+ * Flag indicating permanance of consumer. (if it can be disabled or not)
+ *
+ * @return true indicating that consumer is permanent and cannot be disabled.
+ */
+ public boolean isPermanent();
+
+ /**
+ * Add a consumer monitor to the consumer.
+ *
+ * @param monitor the monitor to add.
+ */
+ public void addConsumerMonitor( ConsumerMonitor monitor );
+
+ /**
+ * Remove a consumer monitor.
+ *
+ * @param monitor the monitor to remove.
+ */
+ public void removeConsumerMonitor( ConsumerMonitor monitor );
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java
new file mode 100644
index 000000000..3b91c5ba3
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java
@@ -0,0 +1,42 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.common.ArchivaException;
+
+/**
+ * ConsumerException - details about the failure of a consumer.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class ConsumerException
+ extends ArchivaException
+{
+ public ConsumerException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public ConsumerException( String message )
+ {
+ super( message );
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
new file mode 100644
index 000000000..971414764
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ConsumerMonitor - a monitor for consumers.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface ConsumerMonitor
+{
+ /**
+ * A consumer error event.
+ *
+ * @param consumer the consumer that caused the error.
+ * @param type the type of error.
+ * @param message the message about the error.
+ */
+ public void consumerError( BaseConsumer consumer, String type, String message );
+
+ /**
+ * A consumer warning event.
+ *
+ * @param consumer the consumer that caused the warning.
+ * @param type the type of warning.
+ * @param message the message about the warning.
+ */
+ public void consumerWarning( BaseConsumer consumer, String type, String message );
+
+ /**
+ * A consumer informational event.
+ *
+ * @param consumer the consumer that caused the informational message.
+ * @param message the message.
+ */
+ public void consumerInfo( BaseConsumer consumer, String message );
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseCleanupConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseCleanupConsumer.java
new file mode 100644
index 000000000..e9bbd0946
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseCleanupConsumer.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * DatabaseCleanupConsumer
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface DatabaseCleanupConsumer
+ extends ArchivaArtifactConsumer
+{
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseUnprocessedArtifactConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseUnprocessedArtifactConsumer.java
new file mode 100644
index 000000000..b34d0dd7f
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/DatabaseUnprocessedArtifactConsumer.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * DatabaseUnprocessedArtifactConsumer
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface DatabaseUnprocessedArtifactConsumer
+ extends ArchivaArtifactConsumer
+{
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/InvalidRepositoryContentConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/InvalidRepositoryContentConsumer.java
new file mode 100644
index 000000000..af31c545a
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/InvalidRepositoryContentConsumer.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Consumer for Invalid Repository Content
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface InvalidRepositoryContentConsumer
+ extends RepositoryContentConsumer
+{
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java
new file mode 100644
index 000000000..884101143
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/KnownRepositoryContentConsumer.java
@@ -0,0 +1,32 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Consumer for Known Repository Content.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface KnownRepositoryContentConsumer
+ extends RepositoryContentConsumer
+{
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
new file mode 100644
index 000000000..9b23e1713
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
@@ -0,0 +1,101 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A consumer of content (files) in the repository.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public interface RepositoryContentConsumer extends BaseConsumer
+{
+ /**
+ * Get the list of included file patterns for this consumer.
+ *
+ * @return the list of {@link String} patterns. (example: "**/*.pom"
)
+ */
+ public List getIncludes();
+
+ /**
+ * Get the list of excluded file patterns for this consumer.
+ *
+ * @return the list of {@link String} patterns. (example: "**/*.pom"
) - (can be null for no exclusions)
+ */
+ public List getExcludes();
+
+ /**
+ *
+ * Event that triggers at the beginning of a scan.
+ *
+ *
+ *
+ * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
+ * generally start tracking the scan as a whole.
+ *
+ *
+ * @param repository the repository that this consumer is being used for.
+ * @param whenGathered the start of the repository scan
+ * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
+ */
+ public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered ) throws ConsumerException;
+
+ /**
+ *
+ * Event indicating a file is to be processed by this consumer.
+ *
+ *
+ *
+ * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
+ * the files to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
+ * event.
+ *
+ *
+ * @param path the relative file path (in the repository) to process.
+ * @throws ConsumerException if there was a problem processing this file.
+ */
+ public void processFile( String path ) throws ConsumerException;
+
+ /**
+ *
+ * Event that triggers on the completion of a scan.
+ *
+ *
+ *
+ * NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(String)} event
+ * this would be the last opportunity to drain any processing queue's.
+ *
+ *
+ * @todo! this is never called by the RepositoryScannerInstance
+ */
+ public void completeScan();
+
+ /**
+ * Whether the consumer should process files that have not been modified since the time passed in to the scan
+ * method.
+ * @return whether to process the unmodified files
+ */
+ boolean isProcessUnmodified();
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/functors/PermanentConsumerPredicate.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/functors/PermanentConsumerPredicate.java
new file mode 100644
index 000000000..92b9e3a55
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/functors/PermanentConsumerPredicate.java
@@ -0,0 +1,48 @@
+package org.apache.maven.archiva.consumers.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.maven.archiva.consumers.BaseConsumer;
+
+/**
+ * Selects Consumers that are flaged as 'permanent'.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class PermanentConsumerPredicate
+ implements Predicate
+{
+
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof BaseConsumer )
+ {
+ BaseConsumer consumer = (BaseConsumer) object;
+ satisfies = consumer.isPermanent();
+ }
+
+ return satisfies;
+ }
+
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
new file mode 100644
index 000000000..8b85df5a0
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
@@ -0,0 +1,73 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.archiva
+ archiva-consumers
+ 1.2-SNAPSHOT
+ ../pom.xml
+
+
+ archiva-core-consumers
+ Archiva Consumers :: Core Consumers
+
+
+
+ org.apache.archiva
+ archiva-database
+
+
+ org.apache.archiva
+ archiva-indexer
+
+
+ org.apache.archiva
+ archiva-configuration
+
+
+ org.apache.archiva
+ archiva-consumer-api
+
+
+ org.apache.archiva
+ archiva-repository-layer
+
+
+ org.codehaus.plexus
+ plexus-digest
+
+
+ org.codehaus.plexus
+ plexus-spring
+ test
+
+
+
+
+ hsqldb
+ hsqldb
+ test
+
+
+ xmlunit
+ xmlunit
+ test
+
+
+
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
new file mode 100644
index 000000000..553289929
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
@@ -0,0 +1,208 @@
+package org.apache.maven.archiva.consumers.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileTypes;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.codehaus.plexus.digest.ChecksumFile;
+import org.codehaus.plexus.digest.Digester;
+import org.codehaus.plexus.digest.DigesterException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ArtifactMissingChecksumsConsumer - Create missing checksums for the artifact.
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * role-hint="create-missing-checksums"
+ * instantiation-strategy="per-lookup"
+ */
+public class ArtifactMissingChecksumsConsumer
+ extends AbstractMonitoredConsumer
+ implements KnownRepositoryContentConsumer, RegistryListener, Initializable
+{
+ /**
+ * @plexus.configuration default-value="create-missing-checksums"
+ */
+ private String id;
+
+ /**
+ * @plexus.configuration default-value="Create Missing Checksums (.sha1 & .md5)"
+ */
+ private String description;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaConfiguration configuration;
+
+ /**
+ * @plexus.requirement
+ */
+ private FileTypes filetypes;
+
+ /**
+ * @plexus.requirement role-hint="sha1"
+ */
+ private Digester digestSha1;
+
+ /**
+ * @plexus.requirement role-hint="md5";
+ */
+ private Digester digestMd5;
+
+ /**
+ * @plexus.requirement
+ */
+ private ChecksumFile checksum;
+
+ private static final String TYPE_CHECKSUM_NOT_FILE = "checksum-bad-not-file";
+
+ private static final String TYPE_CHECKSUM_CANNOT_CALC = "checksum-calc-failure";
+
+ private static final String TYPE_CHECKSUM_CANNOT_CREATE = "checksum-create-failure";
+
+ private File repositoryDir;
+
+ private List propertyNameTriggers = new ArrayList();
+
+ private List includes = new ArrayList();
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public String getDescription()
+ {
+ return this.description;
+ }
+
+ public boolean isPermanent()
+ {
+ return false;
+ }
+
+ public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
+ throws ConsumerException
+ {
+ this.repositoryDir = new File( repo.getLocation() );
+ }
+
+ public void completeScan()
+ {
+ /* do nothing */
+ }
+
+ public List getExcludes()
+ {
+ return getDefaultArtifactExclusions();
+ }
+
+ public List getIncludes()
+ {
+ return includes;
+ }
+
+ public void processFile( String path )
+ throws ConsumerException
+ {
+ createIfMissing( path, digestSha1 );
+ createIfMissing( path, digestMd5 );
+ }
+
+ private void createIfMissing( String path, Digester digester )
+ {
+ File checksumFile = new File( this.repositoryDir, path + digester.getFilenameExtension() );
+ if ( !checksumFile.exists() )
+ {
+ try
+ {
+ checksum.createChecksum( new File( this.repositoryDir, path ), digester );
+ triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() );
+ }
+ catch ( DigesterException e )
+ {
+ triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC,
+ "Cannot calculate checksum for file " + checksumFile + ": " + e.getMessage() );
+ }
+ catch ( IOException e )
+ {
+ triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE,
+ "Cannot create checksum for file " + checksumFile + ": " + e.getMessage() );
+ }
+ }
+ else if ( !checksumFile.isFile() )
+ {
+ triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE,
+ "Checksum file " + checksumFile.getAbsolutePath() + " is not a file." );
+ }
+
+ }
+
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ if ( propertyNameTriggers.contains( propertyName ) )
+ {
+ initIncludes();
+ }
+ }
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ /* do nothing */
+ }
+
+ private void initIncludes()
+ {
+ includes.clear();
+
+ includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+ propertyNameTriggers = new ArrayList();
+ propertyNameTriggers.add( "repositoryScanning" );
+ propertyNameTriggers.add( "fileTypes" );
+ propertyNameTriggers.add( "fileType" );
+ propertyNameTriggers.add( "patterns" );
+ propertyNameTriggers.add( "pattern" );
+
+ configuration.addChangeListener( this );
+
+ initIncludes();
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java
new file mode 100644
index 000000000..618b91f21
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java
@@ -0,0 +1,158 @@
+package org.apache.maven.archiva.consumers.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileTypes;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * AutoRemoveConsumer
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * role-hint="auto-remove"
+ * instantiation-strategy="per-lookup"
+ */
+public class AutoRemoveConsumer
+ extends AbstractMonitoredConsumer
+ implements KnownRepositoryContentConsumer, RegistryListener, Initializable
+{
+ /**
+ * @plexus.configuration default-value="auto-remove"
+ */
+ private String id;
+
+ /**
+ * @plexus.configuration default-value="Automatically Remove File from Filesystem."
+ */
+ private String description;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaConfiguration configuration;
+
+ /**
+ * @plexus.requirement
+ */
+ private FileTypes filetypes;
+
+ private File repositoryDir;
+
+ private List propertyNameTriggers = new ArrayList();
+
+ private List includes = new ArrayList();
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public String getDescription()
+ {
+ return this.description;
+ }
+
+ public boolean isPermanent()
+ {
+ return false;
+ }
+
+ public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
+ throws ConsumerException
+ {
+ this.repositoryDir = new File( repository.getLocation() );
+ }
+
+ public void completeScan()
+ {
+ /* do nothing */
+ }
+
+ public List getExcludes()
+ {
+ return null;
+ }
+
+ public List getIncludes()
+ {
+ return includes;
+ }
+
+ public void processFile( String path )
+ throws ConsumerException
+ {
+ File file = new File( this.repositoryDir, path );
+ if ( file.exists() )
+ {
+ triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath() );
+ file.delete();
+ }
+ }
+
+ public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ if ( propertyNameTriggers.contains( propertyName ) )
+ {
+ initIncludes();
+ }
+ }
+
+ public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+ {
+ /* do nothing */
+ }
+
+ private void initIncludes()
+ {
+ includes.clear();
+
+ includes.addAll( filetypes.getFileTypePatterns( FileTypes.AUTO_REMOVE ) );
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+ propertyNameTriggers = new ArrayList();
+ propertyNameTriggers.add( "repositoryScanning" );
+ propertyNameTriggers.add( "fileTypes" );
+ propertyNameTriggers.add( "fileType" );
+ propertyNameTriggers.add( "patterns" );
+ propertyNameTriggers.add( "pattern" );
+
+ configuration.addChangeListener( this );
+
+ initIncludes();
+ }
+}
diff --git a/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java
new file mode 100644
index 000000000..4c694473e
--- /dev/null
+++ b/MRM-541/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java
@@ -0,0 +1,147 @@
+package org.apache.maven.archiva.consumers.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AutoRenameConsumer
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * role-hint="auto-rename"
+ * instantiation-strategy="per-lookup"
+ */
+public class AutoRenameConsumer
+ extends AbstractMonitoredConsumer
+ implements KnownRepositoryContentConsumer
+{
+ /**
+ * @plexus.configuration default-value="auto-rename"
+ */
+ private String id;
+
+ /**
+ * @plexus.configuration default-value="Automatically rename common artifact mistakes."
+ */
+ private String description;
+
+ private static final String RENAME_FAILURE = "rename_failure";
+
+ private File repositoryDir;
+
+ private List includes = new ArrayList