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;
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() );
// 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 );
}
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;
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;
// 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() );
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() );
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>>();
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,
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;
}
}
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;
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();
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 );
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 );
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();
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();
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();
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();
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 );
| | | |-- 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=
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
+++ /dev/null
-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();
-}
+++ /dev/null
-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<License> licenses;
-
- private Map<String, ProjectBuildFacet> 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<License> getLicenses()
- {
- return licenses;
- }
-
- public void setLicenses( List<License> licenses )
- {
- this.licenses = licenses;
- }
-
- public void addLicense( License license )
- {
- if ( this.licenses == null )
- {
- this.licenses = new ArrayList<License>();
- }
- this.licenses.add( license );
- }
-
- public void addFacet( ProjectBuildFacet mavenProjectFacet )
- {
- if ( this.facets == null )
- {
- this.facets = new HashMap<String, ProjectBuildFacet>();
- }
- this.facets.put( mavenProjectFacet.getFacetId(), mavenProjectFacet );
- }
-
- public ProjectBuildFacet getFacet( String facetId )
- {
- return this.facets.get( facetId );
- }
-}
--- /dev/null
+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();
+}
--- /dev/null
+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<License> licenses;
+
+ private Map<String, ProjectVersionFacet> 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<License> getLicenses()
+ {
+ return licenses;
+ }
+
+ public void setLicenses( List<License> licenses )
+ {
+ this.licenses = licenses;
+ }
+
+ public void addLicense( License license )
+ {
+ if ( this.licenses == null )
+ {
+ this.licenses = new ArrayList<License>();
+ }
+ this.licenses.add( license );
+ }
+
+ public void addFacet( ProjectVersionFacet mavenProjectFacet )
+ {
+ if ( this.facets == null )
+ {
+ this.facets = new HashMap<String, ProjectVersionFacet>();
+ }
+ this.facets.put( mavenProjectFacet.getFacetId(), mavenProjectFacet );
+ }
+
+ public ProjectVersionFacet getFacet( String facetId )
+ {
+ return this.facets.get( facetId );
+ }
+}
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;
/**
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 );
}
}
*/
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 );
}
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 );
}
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 );
}
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;
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 );
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
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();
}
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();
* 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;
* 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;
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
+// }
}
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;
{
/**
* TODO: this isn't suitable for production use
+ *
* @plexus.configuration
*/
private File directory = new File( System.getProperty( "user.home" ), ".archiva-metadata" );
}
}
- 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 )
{
}
}
- 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 );
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 );