aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-12-10 04:16:11 +0000
committerBrett Porter <brett@apache.org>2009-12-10 04:16:11 +0000
commit2c63e15d42b6af0e69a5e2426aeb7c8c30e1af7f (patch)
treee82998063c0dd7589f6ea35f17b1b1b83911653f /archiva-modules/metadata
parent33401e981936f2aa20568ccbeaa0d59bfe6436b4 (diff)
downloadarchiva-2c63e15d42b6af0e69a5e2426aeb7c8c30e1af7f.tar.gz
archiva-2c63e15d42b6af0e69a5e2426aeb7c8c30e1af7f.zip
[MRM-1282] make artifacts load metadata on the fly from a maven2 repo
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@889083 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java31
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java3
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java4
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java2
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java16
5 files changed, 47 insertions, 9 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
index d189f761e..aa762a2ab 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
@@ -22,6 +22,7 @@ package org.apache.archiva.metadata.repository;
import java.util.ArrayList;
import java.util.Collection;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
@@ -187,4 +188,34 @@ public class DefaultMetadataResolver
}
return projectVersions;
}
+
+ public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ Collection<ArtifactMetadata> artifacts =
+ metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion );
+ Collection<ArtifactMetadata> storageArtifacts =
+ storageResolver.getArtifacts( repoId, namespace, projectId, projectVersion,
+ new ExcludesFilter<String>( createArtifactIdList( artifacts ) ) );
+ if ( storageArtifacts != null && !storageArtifacts.isEmpty() )
+ {
+ for ( ArtifactMetadata artifact : storageArtifacts )
+ {
+ metadataRepository.updateArtifact( repoId, namespace, projectId, projectVersion, artifact );
+ }
+ artifacts = new ArrayList<ArtifactMetadata>( artifacts );
+ artifacts.addAll( storageArtifacts );
+ }
+ return artifacts;
+ }
+
+ private Collection<String> createArtifactIdList( Collection<ArtifactMetadata> artifacts )
+ {
+ Collection<String> artifactIds = new ArrayList<String>();
+ for ( ArtifactMetadata artifact : artifacts )
+ {
+ artifactIds.add( artifact.getId() );
+ }
+ return artifactIds;
+ }
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
index 6aeb13515..44354f690 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
@@ -62,7 +62,4 @@ public interface MetadataRepository
List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime );
Collection<String> getRepositories();
-
- public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
- String projectVersion );
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
index d804b60fc..d677a70f1 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
@@ -21,6 +21,7 @@ package org.apache.archiva.metadata.repository;
import java.util.Collection;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference;
@@ -56,4 +57,7 @@ public interface MetadataResolver
Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolverException;
+
+ Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
+ String projectVersion );
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java
index 196cb516f..c877ec8ec 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java
@@ -30,4 +30,6 @@ public interface RepositoryPathTranslator
File toFile( File basedir, String namespace, String projectId );
File toFile( File basedir, String namespace );
+
+ File toFile( File basedir, String namespace, String projectId, String projectVersion );
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java
index a83bb9ca1..236b97bb3 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java
@@ -1,10 +1,5 @@
package org.apache.archiva.metadata.repository.storage;
-import java.util.Collection;
-
-import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.filter.Filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -24,6 +19,12 @@ import org.apache.archiva.metadata.repository.filter.Filter;
* under the License.
*/
+import java.util.Collection;
+
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.repository.filter.Filter;
+
public interface StorageMetadataResolver
extends MetadataResolver
{
@@ -33,5 +34,8 @@ public interface StorageMetadataResolver
Collection<String> getProjects( String repoId, String namespace, Filter<String> filter );
- Collection<String> getProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter );
+ Collection<String> getProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter );
+
+ Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, String projectVersion,
+ Filter<String> filter );
}