diff options
author | Brett Porter <brett@apache.org> | 2009-11-25 15:18:54 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-11-25 15:18:54 +0000 |
commit | 91cb91a8a2120cc8ed5f8c01c8cf263b6e5e2cef (patch) | |
tree | a7a013981e4651e3c09e6db1b8c6792396b5cfda | |
parent | b6cf0bf5fa8f2ebcbba0aa96d8c178a5ab871bd1 (diff) | |
download | archiva-91cb91a8a2120cc8ed5f8c01c8cf263b6e5e2cef.tar.gz archiva-91cb91a8a2120cc8ed5f8c01c8cf263b6e5e2cef.zip |
[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
3 files changed, 25 insertions, 14 deletions
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<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) { // TODO: intercept return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion ); diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index 0e4eb70c6..2fa1f01a3 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -134,9 +134,9 @@ public class FileMetadataRepository return properties; } - public ProjectMetadata getProject( String repoId, String groupId, String projectId ) + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) { - File directory = new File( this.directory, repoId + "/" + projectId ); + File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId ); Properties properties = readProperties( directory ); @@ -146,22 +146,26 @@ public class FileMetadataRepository return project; } - public ProjectVersionMetadata getProjectVersion( String repoId, String groupId, String projectId, + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) { - File directory = new File( this.directory, repoId + "/" + projectId + "/" + projectVersion ); + File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + projectVersion ); Properties properties = readProperties( directory ); - - ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata(); - versionMetadata.setId( properties.getProperty( "id" ) ); + String id = properties.getProperty( "id" ); + ProjectVersionMetadata versionMetadata = null; + if ( id != null ) + { + versionMetadata = new ProjectVersionMetadata(); + versionMetadata.setId( id ); + } return versionMetadata; } public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) { - File directory = new File( this.directory, repoId + "/" + projectId + "/" + projectVersion ); + File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + projectVersion ); Properties properties = readProperties( directory ); |