From 251a0c475af8df1b7f1bbab8312f3969a1db86bb Mon Sep 17 00:00:00 2001
From: Brett Porter
Date: Tue, 25 Mar 2008 13:01:41 +0000
Subject: [PATCH] [MRM-746] unable to include *.xml in artifacts list as it
picks up maven-metadata.xml - consolidate operations that checked if
something was an artifact into FileTypes - add exclusions for the metadata
and supporting files to consumers - add tests
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@640793 13f79535-47bb-0310-9956-ffa450edef68
---
.../archiva/configuration/FileTypes.java | 92 +++++++++++++++----
.../archiva/configuration/FileTypesTest.java | 55 +++++++++++
.../consumers/AbstractMonitoredConsumer.java | 16 ++++
.../ArtifactMissingChecksumsConsumer.java | 2 +-
.../core/MetadataUpdaterConsumer.java | 2 +-
.../repository/RepositoryPurgeConsumer.java | 2 +-
.../core/AbstractArtifactConsumerTest.java | 76 +++++++++++++++
.../ArtifactMissingChecksumsConsumerTest.java | 35 +++++++
.../core/MetadataUpdateConsumerTest.java | 35 +++++++
.../DaysOldRepositoryPurgeTest.java | 10 +-
.../RepositoryPurgeConsumerTest.java | 46 +++++++++-
.../RepositoryPurgeConsumerTest.xml | 4 +
.../archiva-database-consumers/pom.xml | 5 +
.../ArtifactUpdateDatabaseConsumer.java | 2 +-
.../ArtifactUpdateDatabaseConsumerTest.java | 79 ++++++++++++++++
.../ArtifactUpdateDatabaseConsumerTest.xml | 56 +++++++++++
.../ManagedDefaultRepositoryContent.java | 54 +----------
.../ManagedLegacyRepositoryContent.java | 56 +----------
.../repository/content/RepositoryRequest.java | 70 --------------
.../repository/metadata/MetadataTools.java | 24 +----
.../content/RepositoryRequestTest.java | 14 ---
.../archiva/cli/ArtifactCountConsumer.java | 1 +
.../artifact/DuplicateArtifactsConsumer.java | 1 +
.../artifact/LocationArtifactsConsumer.java | 1 +
24 files changed, 502 insertions(+), 236 deletions(-)
create mode 100644 archiva-1.0.x/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java
create mode 100644 archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/AbstractArtifactConsumerTest.java
create mode 100644 archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
create mode 100644 archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/MetadataUpdateConsumerTest.java
create mode 100644 archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.java
create mode 100644 archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.xml
diff --git a/archiva-1.0.x/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java b/archiva-1.0.x/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
index c286eac50..4c529a411 100644
--- a/archiva-1.0.x/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
+++ b/archiva-1.0.x/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
@@ -27,8 +27,11 @@ import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryR
import org.codehaus.plexus.logging.AbstractLogEnabled;
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;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -47,7 +50,7 @@ import java.util.Map;
*/
public class FileTypes
extends AbstractLogEnabled
- implements Initializable
+ implements Initializable, RegistryListener
{
public static final String ARTIFACTS = "artifacts";
@@ -67,11 +70,18 @@ public class FileTypes
*/
private Map> defaultTypeMap = new HashMap>();
+ private List artifactPatterns;
+
+ 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.
*
@@ -80,7 +90,7 @@ public class FileTypes
* - A single item list of
"**/*"
*
*
- *
+ *
* @param id the id to lookup.
* @return the list of patterns.
*/
@@ -106,11 +116,33 @@ public class FileTypes
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 void initialize()
throws InitializationException
{
- /* Initialize Default Type Map */
- defaultTypeMap.clear();
+ // TODO: why is this done by hand?
String errMsg = "Unable to load default archiva configuration for FileTypes: ";
@@ -129,19 +161,7 @@ public class FileTypes
ConfigurationRegistryReader configReader = new ConfigurationRegistryReader();
Configuration defaultConfig = configReader.read( commonsRegistry );
- // Store the default file type declaration.
- List filetypes = defaultConfig.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 );
- }
+ initialiseTypeMap( defaultConfig );
}
catch ( RegistryException e )
{
@@ -163,5 +183,41 @@ public class FileTypes
{
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/archiva-1.0.x/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java b/archiva-1.0.x/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/FileTypesTest.java
new file mode 100644
index 000000000..2236ad97d
--- /dev/null
+++ b/archiva-1.0.x/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.PlexusTestCase;
+
+public class FileTypesTest
+ extends PlexusTestCase
+{
+ 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/archiva-1.0.x/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
index f1c4828fa..d478ea20b 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
@@ -21,8 +21,10 @@ package org.apache.maven.archiva.consumers;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
/**
@@ -37,6 +39,15 @@ public abstract class AbstractMonitoredConsumer
{
private Set monitors = new HashSet();
+ /**
+ * 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.
+ */
+ private static final List DEFAULT_EXCLUSIONS = Arrays.asList( "**/maven-metadata.xml",
+ "**/maven-metadata-*.xml", "**/*.sha1",
+ "**/*.asc", "**/*.md5", "**/*.pgp" );
+
public void addConsumerMonitor( ConsumerMonitor monitor )
{
monitors.add( monitor );
@@ -99,4 +110,9 @@ public abstract class AbstractMonitoredConsumer
{
return false;
}
+
+ protected List getDefaultArtifactExclusions()
+ {
+ return DEFAULT_EXCLUSIONS;
+ }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
index 6b5654900..93f1c63be 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
@@ -126,7 +126,7 @@ public class ArtifactMissingChecksumsConsumer
public List getExcludes()
{
- return null;
+ return getDefaultArtifactExclusions();
}
public List getIncludes()
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
index f99b98c5f..996937b5d 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
@@ -145,7 +145,7 @@ public class MetadataUpdaterConsumer
public List getExcludes()
{
- return null;
+ return getDefaultArtifactExclusions();
}
public List getIncludes()
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
index 6dece0fe6..0fd5ac542 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
@@ -125,7 +125,7 @@ public class RepositoryPurgeConsumer
public List getExcludes()
{
- return null;
+ return getDefaultArtifactExclusions();
}
public List getIncludes()
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/AbstractArtifactConsumerTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/AbstractArtifactConsumerTest.java
new file mode 100644
index 000000000..a6cd3615d
--- /dev/null
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/AbstractArtifactConsumerTest.java
@@ -0,0 +1,76 @@
+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.common.utils.BaseFile;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.configuration.FileTypes;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.repository.scanner.functors.ConsumerWantsFilePredicate;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.File;
+
+public abstract class AbstractArtifactConsumerTest
+ extends PlexusTestCase
+{
+ private File repoLocation;
+
+ protected KnownRepositoryContentConsumer consumer;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.ROLE );
+ FileType fileType =
+ (FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
+ assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
+ fileType.addPattern( "**/*.xml" );
+
+ repoLocation = getTestFile( "target/test-" + getName() + "/test-repo" );
+ }
+
+ public void testConsumption()
+ {
+ File localFile =
+ new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
+
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ BaseFile baseFile = new BaseFile( repoLocation, localFile );
+ predicate.setBasefile( baseFile );
+
+ assertFalse( predicate.evaluate( consumer ) );
+ }
+
+ public void testConsumptionOfOtherMetadata()
+ {
+ File localFile =
+ new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
+
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ BaseFile baseFile = new BaseFile( repoLocation, localFile );
+ predicate.setBasefile( baseFile );
+
+ assertFalse( predicate.evaluate( consumer ) );
+ }
+}
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
new file mode 100644
index 000000000..42f84d39e
--- /dev/null
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
@@ -0,0 +1,35 @@
+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.consumers.KnownRepositoryContentConsumer;
+
+public class ArtifactMissingChecksumsConsumerTest
+ extends AbstractArtifactConsumerTest
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ consumer = (ArtifactMissingChecksumsConsumer) lookup( KnownRepositoryContentConsumer.class.getName(),
+ "create-missing-checksums" );
+ }
+}
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/MetadataUpdateConsumerTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/MetadataUpdateConsumerTest.java
new file mode 100644
index 000000000..b97025fba
--- /dev/null
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/MetadataUpdateConsumerTest.java
@@ -0,0 +1,35 @@
+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.consumers.KnownRepositoryContentConsumer;
+
+public class MetadataUpdateConsumerTest
+ extends AbstractArtifactConsumerTest
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ consumer = (KnownRepositoryContentConsumer) lookup( KnownRepositoryContentConsumer.class.getName(),
+ "metadata-updater" );
+ }
+}
\ No newline at end of file
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
index 9ed788f9f..b887b1f11 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
@@ -19,6 +19,10 @@ package org.apache.maven.archiva.consumers.core.repository;
* under the License.
*/
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexStub;
+import org.apache.maven.archiva.indexer.RepositoryContentIndex;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -27,10 +31,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexStub;
-import org.apache.maven.archiva.indexer.RepositoryContentIndex;
-
/**
* @author Maria Odea Ching
*/
@@ -270,5 +270,5 @@ public class DaysOldRepositoryPurgeTest
versions.add( "2.2-SNAPSHOT" );
populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );
- }
+ }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 5073b74e3..46b290e2d 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -20,12 +20,16 @@ package org.apache.maven.archiva.consumers.core.repository;
*/
import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.utils.BaseFile;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.configuration.FileTypes;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexFactoryStub;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.repository.scanner.functors.ConsumerWantsFilePredicate;
import org.custommonkey.xmlunit.XMLAssert;
import java.io.File;
@@ -38,6 +42,46 @@ import java.util.List;
public class RepositoryPurgeConsumerTest
extends AbstractRepositoryPurgeTest
{
+ public void testConsumption()
+ throws Exception
+ {
+ assertNotConsumed( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
+ }
+
+ public void testConsumptionOfOtherMetadata()
+ throws Exception
+ {
+ assertNotConsumed( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
+ }
+
+ private void assertNotConsumed( String path )
+ throws Exception
+ {
+ ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.ROLE );
+ FileType fileType =
+ (FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
+ assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
+ fileType.addPattern( "**/*.xml" );
+
+ // trigger reload
+ FileTypes fileTypes = (FileTypes) lookup( FileTypes.class );
+ fileTypes.afterConfigurationChange( null, "repositoryScanning.fileTypes", null );
+
+ KnownRepositoryContentConsumer repoPurgeConsumer =
+ (KnownRepositoryContentConsumer) lookup( KnownRepositoryContentConsumer.class, "repository-purge" );
+
+ File repoLocation = getTestFile( "target/test-" + getName() + "/test-repo" );
+
+ File localFile =
+ new File( repoLocation, path );
+
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ BaseFile baseFile = new BaseFile( repoLocation, localFile );
+ predicate.setBasefile( baseFile );
+
+ assertFalse( predicate.evaluate( repoPurgeConsumer ) );
+ }
+
private void setLastModified( String path )
{
File dir = new File( path );
@@ -168,7 +212,7 @@ public class RepositoryPurgeConsumerTest
/**
* Test the snapshot clean consumer on a repository set to NOT clean/delete snapshots based on released versions.
- *
+ *
* @throws Exception
*/
public void testReleasedSnapshotsWereNotCleaned()
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml
index 8ccdc3b44..52e286e66 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml
@@ -44,6 +44,7 @@
org.apache.maven.archiva.configuration.FileTypes
+ retention-count
org.apache.maven.archiva.indexer.RepositoryContentIndexFactory
@@ -101,6 +102,7 @@
org.apache.maven.archiva.configuration.FileTypes
+ retention-count
org.apache.maven.archiva.configuration.FileTypes
@@ -134,6 +136,7 @@
org.apache.maven.archiva.configuration.FileTypes
+ days-old
org.apache.maven.archiva.indexer.RepositoryContentIndexFactory
@@ -191,6 +194,7 @@
org.apache.maven.archiva.configuration.FileTypes
+ days-old
org.apache.maven.archiva.configuration.FileTypes
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml
index bf37c00dd..137e48683 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml
@@ -53,5 +53,10 @@
org.codehaus.plexus
plexus-digest
+
+ hsqldb
+ hsqldb
+ test
+
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
index e6a3d8dd8..5fd947e3f 100644
--- a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
@@ -128,7 +128,7 @@ public class ArtifactUpdateDatabaseConsumer
public List getExcludes()
{
- return null;
+ return getDefaultArtifactExclusions();
}
public List getIncludes()
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.java b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.java
new file mode 100644
index 000000000..7f0add52c
--- /dev/null
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.java
@@ -0,0 +1,79 @@
+package org.apache.maven.archiva.consumers.database;
+
+/*
+ * 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.utils.BaseFile;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.configuration.FileTypes;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.repository.scanner.functors.ConsumerWantsFilePredicate;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.File;
+
+public class ArtifactUpdateDatabaseConsumerTest
+ extends PlexusTestCase
+{
+ private File repoLocation;
+
+ protected KnownRepositoryContentConsumer consumer;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.ROLE );
+ FileType fileType =
+ (FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
+ assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
+ fileType.addPattern( "**/*.xml" );
+
+ repoLocation = getTestFile( "target/test-" + getName() + "/test-repo" );
+
+ consumer =
+ (KnownRepositoryContentConsumer) lookup( KnownRepositoryContentConsumer.class, "update-db-artifact" );
+ }
+
+ public void testConsumption()
+ {
+ File localFile =
+ new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
+
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ BaseFile baseFile = new BaseFile( repoLocation, localFile );
+ predicate.setBasefile( baseFile );
+
+ assertFalse( predicate.evaluate( consumer ) );
+ }
+
+ public void testConsumptionOfOtherMetadata()
+ {
+ File localFile =
+ new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
+
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ BaseFile baseFile = new BaseFile( repoLocation, localFile );
+ predicate.setBasefile( baseFile );
+
+ assertFalse( predicate.evaluate( consumer ) );
+ }
+}
diff --git a/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.xml b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.xml
new file mode 100644
index 000000000..801d957b8
--- /dev/null
+++ b/archiva-1.0.x/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumerTest.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+ org.apache.maven.archiva.database.jdo.JdoAccess
+ archiva
+ org.apache.maven.archiva.database.jdo.JdoAccess
+
+
+ org.codehaus.plexus.jdo.JdoFactory
+ archiva
+
+
+
+
+
+
+ org.codehaus.plexus.jdo.JdoFactory
+ archiva
+ org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory
+
+ org.jpox.PersistenceManagerFactoryImpl
+ org.hsqldb.jdbcDriver
+ sa
+
+ jdbc:hsqldb:mem:testdb
+
+
+ javax.jdo.PersistenceManagerFactoryClass
+ org.jpox.PersistenceManagerFactoryImpl
+
+
+
+
+
+
diff --git a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
index 9de5064e1..dcaafd114 100644
--- a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
+++ b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
@@ -30,16 +30,10 @@ import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.layout.LayoutException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.codehaus.plexus.util.SelectorUtils;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
import java.util.Set;
/**
@@ -55,7 +49,7 @@ import java.util.Set;
*/
public class ManagedDefaultRepositoryContent
extends AbstractDefaultRepositoryContent
- implements ManagedRepositoryContent, Initializable
+ implements ManagedRepositoryContent
{
/**
* @plexus.requirement
@@ -64,8 +58,6 @@ public class ManagedDefaultRepositoryContent
private ManagedRepositoryConfiguration repository;
- private List artifactPatterns;
-
public void deleteVersion( VersionedReference reference )
throws ContentNotFoundException
{
@@ -123,7 +115,7 @@ public class ManagedDefaultRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = toArtifactReference( relativePath );
@@ -250,7 +242,7 @@ public class ManagedDefaultRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = toArtifactReference( relativePath );
@@ -300,13 +292,6 @@ public class ManagedDefaultRepositoryContent
}
}
- public void initialize()
- throws InitializationException
- {
- this.artifactPatterns = new ArrayList();
- initVariables();
- }
-
public void setRepository( ManagedRepositoryConfiguration repository )
{
this.repository = repository;
@@ -386,7 +371,7 @@ public class ManagedDefaultRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = toArtifactReference( relativePath );
@@ -410,35 +395,4 @@ public class ManagedDefaultRepositoryContent
return false;
}
}
-
- private void initVariables()
- {
- synchronized ( this.artifactPatterns )
- {
- this.artifactPatterns.clear();
-
- this.artifactPatterns.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
- }
- }
-
- private boolean matchesArtifactPattern( String relativePath )
- {
- // Correct the slash pattern.
- relativePath = relativePath.replace( '\\', '/' );
-
- Iterator it = this.artifactPatterns.iterator();
- while ( it.hasNext() )
- {
- String pattern = it.next();
-
- if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
- {
- // Found match
- return true;
- }
- }
-
- // No match.
- return false;
- }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java
index c1817af4c..40d3ff117 100644
--- a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java
+++ b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java
@@ -31,15 +31,9 @@ import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.layout.LayoutException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.codehaus.plexus.util.SelectorUtils;
import java.io.File;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
import java.util.Set;
/**
@@ -55,7 +49,7 @@ import java.util.Set;
*/
public class ManagedLegacyRepositoryContent
extends AbstractLegacyRepositoryContent
- implements ManagedRepositoryContent, Initializable
+ implements ManagedRepositoryContent
{
/**
* @plexus.requirement
@@ -64,8 +58,6 @@ public class ManagedLegacyRepositoryContent
private ManagedRepositoryConfiguration repository;
- private List artifactPatterns;
-
public void deleteVersion( VersionedReference reference )
throws ContentNotFoundException
{
@@ -115,7 +107,7 @@ public class ManagedLegacyRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
@@ -321,13 +313,6 @@ public class ManagedLegacyRepositoryContent
}
}
- public void initialize()
- throws InitializationException
- {
- this.artifactPatterns = new ArrayList();
- initVariables();
- }
-
public void setRepository( ManagedRepositoryConfiguration repository )
{
this.repository = repository;
@@ -386,7 +371,7 @@ public class ManagedLegacyRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
@@ -417,7 +402,7 @@ public class ManagedLegacyRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
@@ -449,7 +434,7 @@ public class ManagedLegacyRepositoryContent
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
@@ -467,35 +452,4 @@ public class ManagedLegacyRepositoryContent
}
}
}
-
- private void initVariables()
- {
- synchronized ( this.artifactPatterns )
- {
- this.artifactPatterns.clear();
-
- this.artifactPatterns.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
- }
- }
-
- private boolean matchesArtifactPattern( String relativePath )
- {
- // Correct the slash pattern.
- relativePath = relativePath.replace( '\\', '/' );
-
- Iterator it = this.artifactPatterns.iterator();
- while ( it.hasNext() )
- {
- String pattern = it.next();
-
- if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
- {
- // Found match
- return true;
- }
- }
-
- // No match.
- return false;
- }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
index d473c16d0..6d28d12f2 100644
--- a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
+++ b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
@@ -26,15 +26,6 @@ import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.layout.LayoutException;
import org.apache.maven.archiva.repository.metadata.MetadataTools;
-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 org.codehaus.plexus.util.SelectorUtils;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
/**
* RepositoryRequest is used to determine the type of request that is incoming, and convert it to an appropriate
@@ -47,7 +38,6 @@ import java.util.List;
* role="org.apache.maven.archiva.repository.content.RepositoryRequest"
*/
public class RepositoryRequest
- implements RegistryListener, Initializable
{
/**
* @plexus.requirement
@@ -69,35 +59,6 @@ public class RepositoryRequest
*/
private PathParser legacyPathParser;
- private List artifactPatterns;
-
- /**
- * Test path to see if it is an artifact being requested (or not).
- *
- * @param requestedPath the path to test.
- * @return true if it is an artifact being requested.
- */
- public boolean isArtifact( String requestedPath )
- {
- // Correct the slash pattern.
- String relativePath = requestedPath.replace( '\\', '/' );
-
- Iterator it = this.artifactPatterns.iterator();
- while ( it.hasNext() )
- {
- String pattern = it.next();
-
- if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
- {
- // Found match
- return true;
- }
- }
-
- // No match.
- return false;
- }
-
/**
* Takes an incoming requested path (in "/" format) and gleans the layout
* and ArtifactReference appropriate for that content.
@@ -282,35 +243,4 @@ public class RepositoryRequest
String adjustedPath = repository.toPath( ref );
return adjustedPath + supportfile;
}
-
- public void initialize()
- throws InitializationException
- {
- this.artifactPatterns = new ArrayList();
- initVariables();
- this.archivaConfiguration.addChangeListener( this );
- }
-
- private void initVariables()
- {
- synchronized ( this.artifactPatterns )
- {
- this.artifactPatterns.clear();
- this.artifactPatterns.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
- }
- }
-
- public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
- {
- if ( propertyName.contains( "fileType" ) )
- {
- initVariables();
- }
- }
-
- public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
- {
- /* nothing to do */
-
- }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
index 35af14277..5c35e5b5b 100644
--- a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
+++ b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
@@ -42,7 +42,6 @@ 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 org.codehaus.plexus.util.SelectorUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -796,7 +795,7 @@ public class MetadataTools
String relativePath = PathUtil.getRelative( managedRepository.getRepoRoot(), repoFiles[i] );
- if ( matchesArtifactPattern( relativePath ) )
+ if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = managedRepository.toArtifactReference( relativePath );
@@ -807,25 +806,4 @@ public class MetadataTools
// No artifact was found.
return null;
}
-
- private boolean matchesArtifactPattern( String relativePath )
- {
- // Correct the slash pattern.
- relativePath = relativePath.replace( '\\', '/' );
-
- Iterator it = this.artifactPatterns.iterator();
- while ( it.hasNext() )
- {
- String pattern = it.next();
-
- if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
- {
- // Found match
- return true;
- }
- }
-
- // No match.
- return false;
- }
}
diff --git a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
index 6ee6f874a..1ab8c807a 100644
--- a/archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
+++ b/archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
@@ -209,20 +209,6 @@ public class RepositoryRequestTest
"org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", null, "jar" );
}
- public void testIsArtifact()
- {
- assertTrue( repoRequest.isArtifact( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
- assertTrue( repoRequest.isArtifact( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
- assertTrue( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
-
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
- assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/maven-metadata.xml" ) );
- }
-
public void testIsSupportFile()
{
assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
diff --git a/archiva-1.0.x/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java b/archiva-1.0.x/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
index ccb862c4a..7c9aa368f 100644
--- a/archiva-1.0.x/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
+++ b/archiva-1.0.x/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
@@ -52,6 +52,7 @@ public class ArtifactCountConsumer
public ArtifactCountConsumer()
{
+ // TODO: shouldn't this use filetypes?
includes = new ArrayList();
includes.add( "**/*.pom" );
includes.add( "**/*.jar" );
diff --git a/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactsConsumer.java b/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactsConsumer.java
index 360af29d1..8c4063271 100644
--- a/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactsConsumer.java
+++ b/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactsConsumer.java
@@ -86,6 +86,7 @@ public class DuplicateArtifactsConsumer
*/
private RepositoryContentFactory repositoryFactory;
+ // TODO: why is this not used? If it should be, what about excludes?
private List includes = new ArrayList();
public String getId()
diff --git a/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java b/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
index 1aa9d8223..0dbef2b09 100644
--- a/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
+++ b/archiva-1.0.x/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
@@ -97,6 +97,7 @@ public class LocationArtifactsConsumer
private Map repositoryMap = new HashMap();
+ // TODO: why is this not used? If it should be, what about excludes?
private List includes = new ArrayList();
public String getId()
--
2.39.5