From 46fa8834873fa1aed03fdfc499508203419e033e Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 25 Nov 2009 03:11:22 +0000 Subject: [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 --- .../metadata/ArchivaMetadataCreationConsumer.java | 10 +- .../archiva/web/action/ShowArtifactAction.java | 71 +++++---- .../repository/memory/TestMetadataResolver.java | 20 +-- .../archiva/web/action/ShowArtifactActionTest.java | 24 +-- archiva-modules/metadata/content-model.txt | 8 +- .../archiva/metadata/model/ProjectBuildFacet.java | 25 ---- .../metadata/model/ProjectBuildMetadata.java | 161 --------------------- .../metadata/model/ProjectVersionFacet.java | 25 ++++ .../metadata/model/ProjectVersionMetadata.java | 161 +++++++++++++++++++++ .../repository/DefaultMetadataResolver.java | 16 +- .../metadata/repository/MetadataRepository.java | 9 +- .../metadata/repository/MetadataResolver.java | 6 +- .../storage/RepositoryPathTranslator.java | 4 +- .../maven2/Maven2RepositoryMetadataResolver.java | 13 +- .../maven2/Maven2RepositoryPathTranslator.java | 8 +- .../storage/maven2/MavenProjectFacet.java | 4 +- .../Maven2RepositoryMetadataResolverTest.java | 18 ++- .../repository/file/FileMetadataRepository.java | 30 ++-- 18 files changed, 322 insertions(+), 291 deletions(-) delete mode 100644 archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildFacet.java delete mode 100644 archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildMetadata.java create mode 100644 archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java create mode 100644 archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java 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 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(); 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 projectBuilds = new HashMap(); + private Map projectVersions = new HashMap(); private Map> artifactVersions = new HashMap>(); @@ -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 getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) { - List versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, buildId ) ); + List versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); return ( versions != null ? versions : Collections.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/ProjectBuildFacet.java deleted file mode 100644 index 6b02fc8ce..000000000 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildFacet.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.apache.archiva.metadata.model; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public interface ProjectBuildFacet -{ - 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/ProjectBuildMetadata.java deleted file mode 100644 index 712481745..000000000 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildMetadata.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.apache.archiva.metadata.model; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ProjectBuildMetadata -{ - private String id; - - private String url; - - private String name; - - private String description; - - private Organization organization; - - private IssueManagement issueManagement; - - private Scm scm; - - private CiManagement ciManagement; - - private List licenses; - - private Map facets; - - public String getId() - { - return id; - } - - public void setId( String id ) - { - this.id = id; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public void setName( String name ) - { - this.name = name; - } - - public void setDescription( String description ) - { - this.description = description; - } - - public String getDescription() - { - return description; - } - - public String getUrl() - { - return url; - } - - public String getName() - { - return name; - } - - public Organization getOrganization() - { - return organization; - } - - public void setOrganization( Organization organization ) - { - this.organization = organization; - } - - public IssueManagement getIssueManagement() - { - return issueManagement; - } - - public void setIssueManagement( IssueManagement issueManagement ) - { - this.issueManagement = issueManagement; - } - - public Scm getScm() - { - return scm; - } - - public void setScm( Scm scm ) - { - this.scm = scm; - } - - public CiManagement getCiManagement() - { - return ciManagement; - } - - public void setCiManagement( CiManagement ciManagement ) - { - this.ciManagement = ciManagement; - } - - public List getLicenses() - { - return licenses; - } - - public void setLicenses( List licenses ) - { - this.licenses = licenses; - } - - public void addLicense( License license ) - { - if ( this.licenses == null ) - { - this.licenses = new ArrayList(); - } - this.licenses.add( license ); - } - - public void addFacet( ProjectBuildFacet mavenProjectFacet ) - { - if ( this.facets == null ) - { - this.facets = new HashMap(); - } - this.facets.put( mavenProjectFacet.getFacetId(), mavenProjectFacet ); - } - - public ProjectBuildFacet getFacet( String facetId ) - { - return this.facets.get( facetId ); - } -} diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java new file mode 100644 index 000000000..8cb109fcb --- /dev/null +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionFacet.java @@ -0,0 +1,25 @@ +package org.apache.archiva.metadata.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public interface ProjectVersionFacet +{ + String getFacetId(); +} 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 new file mode 100644 index 000000000..c2add5b4f --- /dev/null +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java @@ -0,0 +1,161 @@ +package org.apache.archiva.metadata.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ProjectVersionMetadata +{ + private String id; + + private String url; + + private String name; + + private String description; + + private Organization organization; + + private IssueManagement issueManagement; + + private Scm scm; + + private CiManagement ciManagement; + + private List licenses; + + private Map facets; + + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + + public void setUrl( String url ) + { + this.url = url; + } + + public void setName( String name ) + { + this.name = name; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + public String getUrl() + { + return url; + } + + public String getName() + { + return name; + } + + public Organization getOrganization() + { + return organization; + } + + public void setOrganization( Organization organization ) + { + this.organization = organization; + } + + public IssueManagement getIssueManagement() + { + return issueManagement; + } + + public void setIssueManagement( IssueManagement issueManagement ) + { + this.issueManagement = issueManagement; + } + + public Scm getScm() + { + return scm; + } + + public void setScm( Scm scm ) + { + this.scm = scm; + } + + public CiManagement getCiManagement() + { + return ciManagement; + } + + public void setCiManagement( CiManagement ciManagement ) + { + this.ciManagement = ciManagement; + } + + public List getLicenses() + { + return licenses; + } + + public void setLicenses( List licenses ) + { + this.licenses = licenses; + } + + public void addLicense( License license ) + { + if ( this.licenses == null ) + { + this.licenses = new ArrayList(); + } + this.licenses.add( license ); + } + + public void addFacet( ProjectVersionFacet mavenProjectFacet ) + { + if ( this.facets == null ) + { + this.facets = new HashMap(); + } + this.facets.put( mavenProjectFacet.getFacetId(), mavenProjectFacet ); + } + + 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 getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection 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 getArtifactVersions( String repoId, String namespace, String projectId, String buildId ); + Collection 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 getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection 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 getArtifactVersions( String repoId, String namespace, String projectId, String buildId ) + public Collection 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 ); -- cgit v1.2.3