summaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata/metadata-repository-api/src/main
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-11-27 00:16:19 +0000
committerBrett Porter <brett@apache.org>2009-11-27 00:16:19 +0000
commit9ca17ec770de3824fec6313c5a095cd7cf107c92 (patch)
tree32245afdf640a26357063c48abb3dcb369f4608f /archiva-modules/metadata/metadata-repository-api/src/main
parentcd4c3cb104aa2ed4153e14a60c322b7845a922da (diff)
downloadarchiva-9ca17ec770de3824fec6313c5a095cd7cf107c92.tar.gz
archiva-9ca17ec770de3824fec6313c5a095cd7cf107c92.zip
[MRM-1283] migrate dependees() / "used by" tab to metadata repository and remove repositoryBrowsing from ShowArtifactAction
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@884727 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata/metadata-repository-api/src/main')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java28
-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.java15
3 files changed, 45 insertions, 1 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 a13061a6f..64f15522d 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
@@ -21,8 +21,10 @@ package org.apache.archiva.metadata.repository;
import java.util.Collection;
+import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
/**
* @plexus.component role="org.apache.archiva.metadata.repository.MetadataResolver"
@@ -38,7 +40,7 @@ public class DefaultMetadataResolver
/**
* FIXME: this needs to be configurable based on storage type, and availability of proxy module
* ... could be a different type since we need methods to modify the storage metadata, which would also allow more
- * appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
+ * appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
*
* @plexus.requirement role-hint="maven2"
*/
@@ -63,6 +65,22 @@ public class DefaultMetadataResolver
metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion );
if ( metadata != null )
{
+ // FIXME: make this a more generic post-processing that plugins can take advantage of
+ // eg. maven projects should be able to process parent here
+ if ( !metadata.getDependencies().isEmpty() )
+ {
+ ProjectVersionReference ref = new ProjectVersionReference();
+ ref.setNamespace( namespace );
+ ref.setProjectId( projectId );
+ ref.setProjectVersion( projectVersion );
+ ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
+ for ( Dependency dependency : metadata.getDependencies() )
+ {
+ metadataRepository.updateProjectReference( repoId, dependency.getGroupId(),
+ dependency.getArtifactId(), dependency.getVersion(),
+ ref );
+ }
+ }
metadataRepository.updateProjectVersion( repoId, namespace, projectId, metadata );
}
}
@@ -75,4 +93,12 @@ public class DefaultMetadataResolver
// TODO: intercept
return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion );
}
+
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ // TODO: is this assumption correct? could a storage mech. actually know all references in a non-Maven scenario?
+ // not passed to the storage mechanism as resolving references would require iterating all artifacts
+ return metadataRepository.getProjectReferences( repoId, namespace, projectId, projectVersion );
+ }
}
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 7b4e23737..a41016be3 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
@@ -22,6 +22,7 @@ package org.apache.archiva.metadata.repository;
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;
public interface MetadataRepository
extends MetadataResolver
@@ -39,4 +40,6 @@ public interface MetadataRepository
void updateProjectVersion( String repoId, String namespace, String projectId,
ProjectVersionMetadata versionMetadata );
+ void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
+ ProjectVersionReference reference );
}
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 7e6aaef7d..e6f8e6316 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
@@ -23,6 +23,7 @@ import java.util.Collection;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
public interface MetadataResolver
{
@@ -32,4 +33,18 @@ public interface MetadataResolver
throws MetadataResolverException;
Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion );
+
+ /**
+ * Retrieve project references from the metadata repository. Note that this is not built into the content model for
+ * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual
+ * project is, and we want to avoid adding a stub model to the content repository.
+ *
+ * @param repoId the repository ID to look within
+ * @param namespace the namespace of the project to get references to
+ * @param projectId the identifier of the project to get references to
+ * @param projectVersion the version of the project to get references to
+ * @return a list of project references
+ */
+ Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion );
}