From 91cb91a8a2120cc8ed5f8c01c8cf263b6e5e2cef Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 25 Nov 2009 15:18:54 +0000 Subject: [MRM-1282] fix some problems with the metadata repository git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@884134 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/metadata/model/ProjectVersionMetadata.java | 2 +- .../metadata/repository/DefaultMetadataResolver.java | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'archiva-modules/metadata') diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java index c2add5b4f..08f4b5a9c 100644 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java @@ -156,6 +156,6 @@ public class ProjectVersionMetadata public ProjectVersionFacet getFacet( String facetId ) { - return this.facets.get( facetId ); + return this.facets != null ? this.facets.get( facetId ) : null; } } 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 e058ca22d..7a2c5f268 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 @@ -37,7 +37,8 @@ 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 + * ... could be a different type since we need methods to modify the storage metadata + * * @plexus.requirement role-hint="maven2" */ private MetadataResolver storageResolver; @@ -48,21 +49,27 @@ public class DefaultMetadataResolver return metadataRepository.getProject( repoId, namespace, projectId ); } - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolverException { - ProjectVersionMetadata metadata = metadataRepository.getProjectVersion( repoId, namespace, projectId, projectVersion ); + ProjectVersionMetadata metadata = + metadataRepository.getProjectVersion( repoId, namespace, projectId, projectVersion ); // TODO: do we want to detect changes as well by comparing timestamps? isProjectVersionNewerThan(updated) // in such cases we might also remove/update stale metadata, including adjusting plugin-based facets if ( metadata == null ) { metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion ); - metadataRepository.updateProjectVersion( repoId, namespace, projectId, metadata ); + if ( metadata != null ) + { + metadataRepository.updateProjectVersion( repoId, namespace, projectId, metadata ); + } } return metadata; } - public Collection getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) + public Collection getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) { // TODO: intercept return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion ); -- cgit v1.2.3