diff options
author | Brett Porter <brett@apache.org> | 2009-11-25 03:11:22 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-11-25 03:11:22 +0000 |
commit | 46fa8834873fa1aed03fdfc499508203419e033e (patch) | |
tree | 82d0a4f247dec5c437bd8b364cc8cc33bc406693 | |
parent | 7d2c217bdb9c752a573f20827c102eed6a924a54 (diff) | |
download | archiva-46fa8834873fa1aed03fdfc499508203419e033e.tar.gz archiva-46fa8834873fa1aed03fdfc499508203419e033e.zip |
[MRM-1282] clear up confusing "build" terminology, instead using project version (1.0-SNAPSHOT) and artifact version (1.0-20091112.0123456-1)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@883965 13f79535-47bb-0310-9956-ffa450edef68
16 files changed, 142 insertions, 111 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index d91e96cc1..44c03754f 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -25,7 +25,7 @@ import java.util.Date; import java.util.List; import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.maven.archiva.configuration.ArchivaConfiguration; @@ -142,8 +142,8 @@ public class ArchivaMetadataCreationConsumer project.setNamespace( artifact.getGroupId() ); project.setId( artifact.getArtifactId() ); - ProjectBuildMetadata build = new ProjectBuildMetadata(); - build.setId( artifact.getVersion() ); // TODO: this should be the version from the POM, not the timestamped version + ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata(); + versionMetadata.setId( artifact.getVersion() ); // TODO: this should be the version from the POM, not the timestamped version ArtifactMetadata artifactMeta = new ArtifactMetadata(); artifactMeta.setId( file.getName() ); @@ -157,8 +157,8 @@ public class ArchivaMetadataCreationConsumer // TODO: transaction // read the metadata and update it if it is newer or doesn't exist - metadataRepository.updateArtifact( repository.getId(), project.getNamespace(), project.getId(), build.getId(), artifactMeta ); - metadataRepository.updateBuild( repository.getId(), project.getNamespace(), project.getId(), build ); + metadataRepository.updateArtifact( repository.getId(), project.getNamespace(), project.getId(), versionMetadata.getId(), artifactMeta ); + metadataRepository.updateProjectVersion( repository.getId(), project.getNamespace(), project.getId(), versionMetadata ); metadataRepository.updateProject( repository.getId(), project ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java index e63468430..1fb439012 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; import com.opensymphony.xwork2.Validateable; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataResolver; import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet; import org.apache.commons.lang.StringUtils; @@ -100,32 +100,39 @@ public class ShowArtifactAction private List<String> snapshotVersions; /** - * Show the versioned project information tab. TODO: Change name to 'project' + * Show the versioned project information tab. + * TODO: Change name to 'project' - we are showing project versions here, not specific artifact information (though + * that is rendered in the download box). */ public String artifact() { // In the future, this should be replaced by the repository grouping mechanism, so that we are only making // simple resource requests here and letting the resolver take care of it - ProjectBuildMetadata build = null; + ProjectVersionMetadata versionMetadata = null; snapshotVersions = new ArrayList<String>(); for ( String repoId : getObservableRepos() ) { - if ( build == null ) + if ( versionMetadata == null ) { - // we don't really want the implementation being that intelligent - so another resolver to do the + // TODO: though we have a simple mapping now, do we want to support paths like /1.0-20090111.123456-1/ + // again by mapping it to /1.0-SNAPSHOT/? Currently, the individual versions are not supported as we + // are only displaying the project's single version. + + // we don't want the implementation being that intelligent - so another resolver to do the // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used - build = metadataResolver.getProjectBuild( repoId, groupId, artifactId, version ); - if ( build != null ) + versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); + if ( versionMetadata != null ) { - repositoryId = repoId; + repositoryId = repoId; + + snapshotVersions.addAll( + metadataResolver.getArtifactVersions( repoId, groupId, artifactId, versionMetadata.getId() ) ); + snapshotVersions.remove( version ); } } - - snapshotVersions.addAll( metadataResolver.getArtifactVersions( repoId, groupId, artifactId, version ) ); - snapshotVersions.remove( version ); } - if ( build == null ) + if ( versionMetadata == null ) { addActionError( "Artifact not found" ); return ERROR; @@ -133,7 +140,7 @@ public class ShowArtifactAction // TODO: eventually, move to just use the metadata directly, with minimal JSP changes, mostly for Maven specifics model = new ArchivaProjectModel(); - MavenProjectFacet projectFacet = (MavenProjectFacet) build.getFacet( MavenProjectFacet.FACET_ID ); + MavenProjectFacet projectFacet = (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID ); model.setGroupId( projectFacet.getGroupId() ); model.setArtifactId( projectFacet.getArtifactId() ); model.setPackaging( projectFacet.getPackaging() ); @@ -146,42 +153,42 @@ public class ShowArtifactAction model.setParentProject( parent ); } - model.setVersion( build.getId() ); - model.setDescription( build.getDescription() ); - model.setName( build.getName() ); - model.setUrl( build.getUrl() ); - if ( build.getOrganization() != null ) + model.setVersion( versionMetadata.getId() ); + model.setDescription( versionMetadata.getDescription() ); + model.setName( versionMetadata.getName() ); + model.setUrl( versionMetadata.getUrl() ); + if ( versionMetadata.getOrganization() != null ) { Organization organization = new Organization(); - organization.setName( build.getOrganization().getName() ); - organization.setUrl( build.getOrganization().getUrl() ); + organization.setName( versionMetadata.getOrganization().getName() ); + organization.setUrl( versionMetadata.getOrganization().getUrl() ); model.setOrganization( organization ); } - if ( build.getCiManagement() != null ) + if ( versionMetadata.getCiManagement() != null ) { CiManagement ci = new CiManagement(); - ci.setSystem( build.getCiManagement().getSystem() ); - ci.setUrl( build.getCiManagement().getUrl() ); + ci.setSystem( versionMetadata.getCiManagement().getSystem() ); + ci.setUrl( versionMetadata.getCiManagement().getUrl() ); model.setCiManagement( ci ); } - if ( build.getIssueManagement() != null ) + if ( versionMetadata.getIssueManagement() != null ) { IssueManagement issueManagement = new IssueManagement(); - issueManagement.setSystem( build.getIssueManagement().getSystem() ); - issueManagement.setUrl( build.getIssueManagement().getUrl() ); + issueManagement.setSystem( versionMetadata.getIssueManagement().getSystem() ); + issueManagement.setUrl( versionMetadata.getIssueManagement().getUrl() ); model.setIssueManagement( issueManagement ); } - if ( build.getScm() != null ) + if ( versionMetadata.getScm() != null ) { Scm scm = new Scm(); - scm.setConnection( build.getScm().getConnection() ); - scm.setDeveloperConnection( build.getScm().getDeveloperConnection() ); - scm.setUrl( build.getScm().getUrl() ); + scm.setConnection( versionMetadata.getScm().getConnection() ); + scm.setDeveloperConnection( versionMetadata.getScm().getDeveloperConnection() ); + scm.setUrl( versionMetadata.getScm().getUrl() ); model.setScm( scm ); } - if ( build.getLicenses() != null ) + if ( versionMetadata.getLicenses() != null ) { - for ( org.apache.archiva.metadata.model.License l : build.getLicenses() ) + for ( org.apache.archiva.metadata.model.License l : versionMetadata.getLicenses() ) { License license = new License(); license.setName( l.getName() ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java index 40670f7d6..2b48830dc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java @@ -25,14 +25,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.repository.MetadataResolver; public class TestMetadataResolver implements MetadataResolver { - private Map<String, ProjectBuildMetadata> projectBuilds = new HashMap<String, ProjectBuildMetadata>(); + private Map<String, ProjectVersionMetadata> projectVersions = new HashMap<String, ProjectVersionMetadata>(); private Map<String, List<String>> artifactVersions = new HashMap<String, List<String>>(); @@ -44,20 +44,20 @@ public class TestMetadataResolver return metadata; } - public ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId ) + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) { - return projectBuilds.get( createMapKey( repoId, namespace, projectId, buildId ) ); + return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); } - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) { - List<String> versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, buildId ) ); + List<String> versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); return ( versions != null ? versions : Collections.<String>emptyList() ); } - public void setProjectBuild( String repoId, String namespace, String projectId, ProjectBuildMetadata build ) + public void setProjectVersion( String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata ) { - projectBuilds.put( createMapKey( repoId, namespace, projectId, build.getId() ), build ); + projectVersions.put( createMapKey( repoId, namespace, projectId, versionMetadata.getId() ), versionMetadata ); } public void setArtifactVersions( String repoId, String namespace, String projectId, String version, @@ -66,8 +66,8 @@ public class TestMetadataResolver artifactVersions.put( createMapKey( repoId, namespace, projectId, version ), versions ); } - private String createMapKey( String repoId, String namespace, String projectId, String buildId ) + private String createMapKey( String repoId, String namespace, String projectId, String projectVersion ) { - return repoId + ":" + namespace + ":" + projectId + ":" + buildId; + return repoId + ":" + namespace + ":" + projectId + ":" + projectVersion; } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java index 56e5d1d73..58341922e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java @@ -28,7 +28,7 @@ import org.apache.archiva.metadata.model.CiManagement; import org.apache.archiva.metadata.model.IssueManagement; import org.apache.archiva.metadata.model.License; import org.apache.archiva.metadata.model.Organization; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.Scm; import org.apache.archiva.metadata.repository.memory.TestMetadataResolver; import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet; @@ -111,7 +111,7 @@ public class ShowArtifactActionTest public void testGetArtifactUniqueRelease() { - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); setActionParameters(); @@ -134,7 +134,7 @@ public class ShowArtifactActionTest public void testGetArtifactUniqueSnapshot() { - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_SNAPSHOT_VERSION ) ); metadataResolver.setArtifactVersions( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION, ALL_TEST_SNAPSHOT_VERSIONS ); @@ -164,7 +164,7 @@ public class ShowArtifactActionTest public void testGetArtifactUniqueSnapshotTimestamped() { - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_TS_SNAPSHOT_VERSION ) ); metadataResolver.setArtifactVersions( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_TS_SNAPSHOT_VERSION, ALL_TEST_SNAPSHOT_VERSIONS ); @@ -220,7 +220,7 @@ public class ShowArtifactActionTest public void testGetArtifactNotInObservableRepos() { - metadataResolver.setProjectBuild( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); setActionParameters(); @@ -235,7 +235,7 @@ public class ShowArtifactActionTest public void testGetArtifactOnlySeenInSecondObservableRepo() { setObservableRepos( Arrays.asList( OTHER_TEST_REPO, TEST_REPO ) ); - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); setActionParameters(); @@ -259,9 +259,9 @@ public class ShowArtifactActionTest public void testGetArtifactSeenInBothObservableRepo() { setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) ); - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); - metadataResolver.setProjectBuild( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); setActionParameters(); @@ -285,9 +285,9 @@ public class ShowArtifactActionTest public void testGetArtifactCanOnlyObserveInOneOfTwoRepos() { setObservableRepos( Arrays.asList( TEST_REPO ) ); - metadataResolver.setProjectBuild( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); - metadataResolver.setProjectBuild( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, + metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel( TEST_VERSION ) ); setActionParameters(); @@ -386,9 +386,9 @@ public class ShowArtifactActionTest assertTrue( action.getActionMessages().isEmpty() ); } - private ProjectBuildMetadata createProjectModel( String version ) + private ProjectVersionMetadata createProjectModel( String version ) { - ProjectBuildMetadata model = new ProjectBuildMetadata(); + ProjectVersionMetadata model = new ProjectVersionMetadata(); model.setId( version ); model.setUrl( TEST_URL ); model.setName( TEST_NAME ); diff --git a/archiva-modules/metadata/content-model.txt b/archiva-modules/metadata/content-model.txt index d874634b1..6f9511572 100644 --- a/archiva-modules/metadata/content-model.txt +++ b/archiva-modules/metadata/content-model.txt @@ -24,7 +24,7 @@ The following is the intended content model for the metadata content repository: | | | |-- sha1= | | | |-- size= | | | |-- updated= - | | | `-- version= -- the actual version of the file + | | | `-- version= -- the actual version of the file, 1.0-20091120.012345-1 | | |-- created= | | |-- description= | | |-- name= @@ -51,4 +51,8 @@ file in the original storageUrl when it is requested 4) The API will still use separate namespace and project identifiers (the namespace can be null if there isn't one). This is chosen to allow splitting the namespace on '.', and also allowing '.' in the project identifier without splitting -5) properties with '.' may be nested in other representations such as Java models or XML, if appropriate
\ No newline at end of file +5) properties with '.' may be nested in other representations such as Java models or XML, if appropriate + +6) we only keep one set of project information for a "version" - this differs from Maven's storage of one POM per snapshot. The Maven 2 module will + take the latest. Those that need Maven's behaviour should retrieve the POM directly. Implementations are also free to store as much information + as desired within the artifact node in addition to whatever is shared in the project version node.
\ No newline at end of file diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildFacet.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java index 6b02fc8ce..8cb109fcb 100644 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildFacet.java +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java @@ -19,7 +19,7 @@ package org.apache.archiva.metadata.model; * under the License. */ -public interface ProjectBuildFacet +public interface ProjectVersionFacet { String getFacetId(); } diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java index 712481745..c2add5b4f 100644 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildMetadata.java +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class ProjectBuildMetadata +public class ProjectVersionMetadata { private String id; @@ -44,7 +44,7 @@ public class ProjectBuildMetadata private List<License> licenses; - private Map<String, ProjectBuildFacet> facets; + private Map<String, ProjectVersionFacet> facets; public String getId() { @@ -145,16 +145,16 @@ public class ProjectBuildMetadata this.licenses.add( license ); } - public void addFacet( ProjectBuildFacet mavenProjectFacet ) + public void addFacet( ProjectVersionFacet mavenProjectFacet ) { if ( this.facets == null ) { - this.facets = new HashMap<String, ProjectBuildFacet>(); + this.facets = new HashMap<String, ProjectVersionFacet>(); } this.facets.put( mavenProjectFacet.getFacetId(), mavenProjectFacet ); } - public ProjectBuildFacet getFacet( String facetId ) + public ProjectVersionFacet getFacet( String facetId ) { return this.facets.get( facetId ); } 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 d7837a8a3..39d250aa6 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,7 +21,7 @@ package org.apache.archiva.metadata.repository; import java.util.Collection; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; /** @@ -48,22 +48,22 @@ public class DefaultMetadataResolver return metadataRepository.getProject( repoId, namespace, projectId ); } - public ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId ) + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) { - ProjectBuildMetadata metadata = metadataRepository.getProjectBuild( repoId, namespace, projectId, buildId ); - // TODO: do we want to detect changes as well by comparing timestamps? isProjectBuildNewerThan(updated) + 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.getProjectBuild( repoId, namespace, projectId, buildId ); - metadataRepository.updateBuild( repoId, namespace, projectId, metadata ); + metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion ); + metadataRepository.updateProjectVersion( repoId, namespace, projectId, metadata ); } return metadata; } - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) { // TODO: intercept - return metadataRepository.getArtifactVersions( repoId, namespace, projectId, buildId ); + return metadataRepository.getArtifactVersions( 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 6e20282c1..7b4e23737 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 @@ -20,20 +20,23 @@ package org.apache.archiva.metadata.repository; */ import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; public interface MetadataRepository extends MetadataResolver { /** * Update metadata for a particular project in the metadata repository, or create it if it does not already exist. + * * @param project the project metadata to create or update */ void updateProject( String repoId, ProjectMetadata project ); - void updateArtifact( String repoId, String namespace, String projectId, String buildId, ArtifactMetadata artifactMeta ); + void updateArtifact( String repoId, String namespace, String projectId, String projectVersion, + ArtifactMetadata artifactMeta ); - void updateBuild( String repoId, String namespace, String projectId, ProjectBuildMetadata build ); + void updateProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ); } 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 fd2cf83d4..7050b0552 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,14 +21,14 @@ package org.apache.archiva.metadata.repository; import java.util.Collection; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; public interface MetadataResolver { ProjectMetadata getProject( String repoId, String namespace, String projectId ); - ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId ); + ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ); - Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId ); + Collection<String> getArtifactVersions( 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 3a581d696..f7a50e7d5 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 @@ -23,7 +23,7 @@ import java.io.File; public interface RepositoryPathTranslator { - File toFile( File basedir, String namespace, String projectId, String buildId, String filename ); + File toFile( File basedir, String namespace, String projectId, String projectVersion, String filename ); - String toPath( String namespace, String projectId, String buildId, String filename ); + String toPath( String namespace, String projectId, String projectVersion, String filename ); } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java index ff414d844..4fa121373 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java @@ -22,7 +22,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; import java.io.File; import java.util.Collection; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.repository.MetadataResolver; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; @@ -60,13 +60,16 @@ public class Maven2RepositoryMetadataResolver throw new UnsupportedOperationException(); } - public ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId ) + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) { + // TODO: artifactVersion translation + ManagedRepositoryConfiguration repositoryConfiguration = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId ); File basedir = new File( repositoryConfiguration.getLocation() ); - File file = pathTranslator.toFile( basedir, namespace, projectId, buildId, projectId + "-" + buildId + ".pom" ); + File file = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, projectId + "-" + + projectVersion + ".pom" ); ModelBuildingRequest req = new DefaultModelBuildingRequest(); req.setProcessPlugins( false ); @@ -96,7 +99,7 @@ public class Maven2RepositoryMetadataResolver parent.setVersion( model.getParent().getVersion() ); facet.setParent( parent ); } - ProjectBuildMetadata metadata = new ProjectBuildMetadata(); + ProjectVersionMetadata metadata = new ProjectVersionMetadata(); metadata.setUrl( model.getUrl() ); metadata.addFacet( facet ); // TODO: convert project @@ -104,7 +107,7 @@ public class Maven2RepositoryMetadataResolver return metadata; } - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) { throw new UnsupportedOperationException(); } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java index 53cabacaa..3f5bcc83d 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java @@ -33,18 +33,18 @@ public class Maven2RepositoryPathTranslator private static final char GROUP_SEPARATOR = '.'; - public File toFile( File basedir, String namespace, String projectId, String buildId, String filename ) + public File toFile( File basedir, String namespace, String projectId, String projectVersion, String filename ) { - return new File( basedir, toPath( namespace, projectId, buildId, filename ) ); + return new File( basedir, toPath( namespace, projectId, projectVersion, filename ) ); } - public String toPath( String namespace, String projectId, String buildId, String filename ) + public String toPath( String namespace, String projectId, String projectVersion, String filename ) { StringBuilder path = new StringBuilder(); path.append( formatAsDirectory( namespace ) ).append( PATH_SEPARATOR ); path.append( projectId ).append( PATH_SEPARATOR ); - path.append( buildId ).append( PATH_SEPARATOR ); + path.append( projectVersion ).append( PATH_SEPARATOR ); path.append( filename ); return path.toString(); diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java index dd68adb85..fbcc31b75 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java @@ -19,10 +19,10 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.metadata.model.ProjectBuildFacet; +import org.apache.archiva.metadata.model.ProjectVersionFacet; public class MavenProjectFacet - implements ProjectBuildFacet + implements ProjectVersionFacet { private String groupId; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index a1dde6b68..748b3b7ac 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -19,7 +19,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.metadata.model.ProjectBuildMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataResolver; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -49,13 +49,23 @@ public class Maven2RepositoryMetadataResolverTest resolver = (Maven2RepositoryMetadataResolver) lookup( MetadataResolver.class, "maven2" ); } - public void testGetProjectBuildMetadata() + public void testGetProjectVersionMetadata() { - ProjectBuildMetadata metadata = - resolver.getProjectBuild( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" ); + ProjectVersionMetadata metadata = + resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() ); // TODO: more testing } + +// public void testGetProjectVersionMetadataForTimestampedSnapshot() +// { +// ProjectVersionMetadata metadata = +// resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" ); +// MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); +// assertEquals( "jar", facet.getPackaging() ); +// assertEquals( "http://www.apache.org/", metadata.getUrl() ); +// // TODO: more testing +// } } 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 54a755c87..0e4eb70c6 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 @@ -31,8 +31,8 @@ import java.util.Map; import java.util.Properties; import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectBuildMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.commons.io.IOUtils; @@ -44,6 +44,7 @@ public class FileMetadataRepository { /** * TODO: this isn't suitable for production use + * * @plexus.configuration */ private File directory = new File( System.getProperty( "user.home" ), ".archiva-metadata" ); @@ -67,16 +68,17 @@ public class FileMetadataRepository } } - public void updateBuild( String repoId, String namespace, String projectId, ProjectBuildMetadata build ) + public void updateProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) { File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId ); Properties properties = new Properties(); - properties.setProperty( "id", build.getId() ); + properties.setProperty( "id", versionMetadata.getId() ); try { - writeProperties( properties, new File( directory, build.getId() ) ); + writeProperties( properties, new File( directory, versionMetadata.getId() ) ); } catch ( IOException e ) { @@ -85,10 +87,10 @@ public class FileMetadataRepository } } - public void updateArtifact( String repoId, String namespace, String projectId, String buildId, + public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion, ArtifactMetadata artifact ) { - File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + buildId ); + File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + projectVersion ); Properties properties = readProperties( directory ); @@ -144,20 +146,22 @@ public class FileMetadataRepository return project; } - public ProjectBuildMetadata getProjectBuild( String repoId, String groupId, String projectId, String buildId ) + public ProjectVersionMetadata getProjectVersion( String repoId, String groupId, String projectId, + String projectVersion ) { - File directory = new File( this.directory, repoId + "/" + projectId + "/" + buildId ); + File directory = new File( this.directory, repoId + "/" + projectId + "/" + projectVersion ); Properties properties = readProperties( directory ); - ProjectBuildMetadata build = new ProjectBuildMetadata(); - build.setId( properties.getProperty( "id" ) ); - return build; + ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata(); + versionMetadata.setId( properties.getProperty( "id" ) ); + return versionMetadata; } - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) { - File directory = new File( this.directory, repoId + "/" + projectId + "/" + buildId ); + File directory = new File( this.directory, repoId + "/" + projectId + "/" + projectVersion ); Properties properties = readProperties( directory ); |