import com.opensymphony.xwork2.Validateable;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.MetadataResolverException;
import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.database.ObjectNotFoundException;
-import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.CiManagement;
import org.apache.maven.archiva.model.Dependency;
{
/* .\ Not Exposed \._____________________________________________ */
- /**
- * @plexus.requirement role-hint="default"
- */
- private RepositoryBrowsing repoBrowsing;
-
/**
* @plexus.requirement
*/
addActionError( "Artifact not found" );
return ERROR;
}
- populateLegacyModel( versionMetadata );
+ model = populateLegacyModel( versionMetadata );
return SUCCESS;
}
- private void populateLegacyModel( ProjectVersionMetadata versionMetadata )
+ private ArchivaProjectModel populateLegacyModel( ProjectVersionMetadata versionMetadata )
{
// TODO: eventually, move to just use the metadata directly, with minimal JSP changes, mostly for Maven specifics
- model = new ArchivaProjectModel();
+ ArchivaProjectModel model = new ArchivaProjectModel();
MavenProjectFacet projectFacet = (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
if ( projectFacet != null )
{
model.addDependency( dependency );
}
}
+ return model;
}
/**
addActionError( "Artifact not found" );
return ERROR;
}
- populateLegacyModel( versionMetadata );
+ model = populateLegacyModel( versionMetadata );
this.dependencies = model.getDependencies();
addActionError( "Artifact not found" );
return ERROR;
}
- populateLegacyModel( versionMetadata );
+ model = populateLegacyModel( versionMetadata );
this.mailingLists = model.getMailingLists();
public String dependees()
throws ObjectNotFoundException, ArchivaDatabaseException
{
- this.model = repoBrowsing.selectVersion( getPrincipal(), getObservableRepos(), groupId, artifactId, version );
+ ProjectVersionMetadata versionMetadata = null;
+ for ( String repoId : getObservableRepos() )
+ {
+ if ( versionMetadata == null )
+ {
+ try
+ {
+ versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
+ }
+ catch ( MetadataResolverException e )
+ {
+ addActionError( "Error occurred resolving metadata for project: " + e.getMessage() );
+ return ERROR;
+ }
+ }
+ }
+
+ if ( versionMetadata == null )
+ {
+ addActionError( "Artifact not found" );
+ return ERROR;
+ }
+ model = populateLegacyModel( versionMetadata );
+
+ List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
+ // TODO: what if we get duplicates across repositories?
+ for ( String repoId : getObservableRepos() )
+ {
+ // TODO: what about if we want to see this irrespective of version?
+ references.addAll( metadataResolver.getProjectReferences( repoId, groupId, artifactId, version ) );
+ }
+
+ this.dependees = new ArrayList<ArchivaProjectModel>();
+ for ( ProjectVersionReference reference : references )
+ {
+ ArchivaProjectModel ref = new ArchivaProjectModel();
- this.dependees = repoBrowsing.getUsedBy( getPrincipal(), getObservableRepos(), groupId, artifactId, version );
+ ref.setGroupId( reference.getNamespace() );
+ ref.setArtifactId( reference.getProjectId() );
+ ref.setVersion( reference.getProjectVersion() );
+
+ dependees.add( ref );
+ }
+
+ // TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet stored in the content repository
+ // (especially in the case of pre-population import)
return SUCCESS;
}
// temporarily use this as we only need the model for the tag to perform, but we should be resolving the
// graph here instead
+ // TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in the content repository
+ // (especially in the case of pre-population import)
+
return artifact();
}
import java.util.List;
import java.util.Map;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.repository.MetadataResolver;
public class TestMetadataResolver
private Map<String, List<String>> artifactVersions = new HashMap<String, List<String>>();
+ private Map<String, List<ProjectVersionReference>> references =
+ new HashMap<String, List<ProjectVersionReference>>();
+
public ProjectMetadata getProject( String repoId, String namespace, String projectId )
{
ProjectMetadata metadata = new ProjectMetadata();
return metadata;
}
- public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+ public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
+ String projectVersion )
{
return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
}
- public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion )
+ public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
+ String projectVersion )
{
List<String> versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
return ( versions != null ? versions : Collections.<String>emptyList() );
}
- public void setProjectVersion( String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata )
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ return references.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
+ }
+
+ public void setProjectVersion( String repoId, String namespace, String projectId,
+ ProjectVersionMetadata versionMetadata )
{
projectVersions.put( createMapKey( repoId, namespace, projectId, versionMetadata.getId() ), versionMetadata );
}
- public void setArtifactVersions( String repoId, String namespace, String projectId, String version,
+ public void setArtifactVersions( String repoId, String namespace, String projectId, String projectVersion,
List<String> versions )
{
- artifactVersions.put( createMapKey( repoId, namespace, projectId, version ), versions );
+ artifactVersions.put( createMapKey( repoId, namespace, projectId, projectVersion ), versions );
}
private String createMapKey( String repoId, String namespace, String projectId, String projectVersion )
{
return repoId + ":" + namespace + ":" + projectId + ":" + projectVersion;
}
+
+ public void setProjectReferences( String repoId, String namespace, String projectId, String projectVersion,
+ List<ProjectVersionReference> references )
+ {
+ this.references.put( createMapKey( repoId, namespace, projectId, projectVersion ), references );
+ }
}
import org.apache.archiva.metadata.model.MailingList;
import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.model.Scm;
import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectParent;
-import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.ProjectModelDAO;
-import org.apache.maven.archiva.database.constraints.ArtifactsRelatedConstraint;
-import org.apache.maven.archiva.database.constraints.ProjectsByArtifactUsageConstraint;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-import org.apache.maven.archiva.model.ArchivaArtifactModel;
import org.apache.maven.archiva.model.ArchivaProjectModel;
-import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.security.UserRepositories;
import org.apache.maven.archiva.security.UserRepositoriesStub;
-import org.apache.maven.archiva.web.action.admin.repositories.ArchivaDAOStub;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-import org.easymock.MockControl;
public class ShowArtifactActionTest
extends PlexusInSpringTestCase
private ShowArtifactAction action;
- private ArchivaDAOStub archivaDao;
-
private TestMetadataResolver metadataResolver;
public void testInstantiation()
public void testGetDependees()
throws ArchivaDatabaseException
{
- List<ArchivaArtifact> artifacts =
- Collections.singletonList( createArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ) );
- MockControl artifactDaoMockControl = createArtifactDaoMock( artifacts, 1 );
- ArchivaProjectModel legacyModel = createLegacyProjectModel( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION );
-
- MockControl projectDaoMockControl = MockControl.createNiceControl( ProjectModelDAO.class );
- ProjectModelDAO dao = (ProjectModelDAO) projectDaoMockControl.getMock();
- archivaDao.setProjectDao( dao );
-
- projectDaoMockControl.expectAndReturn(
- dao.getProjectModel( legacyModel.getGroupId(), legacyModel.getArtifactId(), legacyModel.getVersion() ),
- legacyModel );
-
- ArchivaProjectModel dependee1 = createBasicLegacyModel( "groupId", "artifactId1", "version" );
- ArchivaProjectModel dependee2 = createBasicLegacyModel( "groupId", "artifactId2", "version" );
- projectDaoMockControl.expectAndReturn( dao.queryProjectModels(
- new ProjectsByArtifactUsageConstraint( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ) ),
+ ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+ metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+ ProjectVersionReference dependee1 = createReference( "artifactId1" );
+ ProjectVersionReference dependee2 = createReference( "artifactId2" );
+ metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION,
Arrays.asList( dependee1, dependee2 ) );
- projectDaoMockControl.replay();
-
setActionParameters();
String result = action.dependees();
- artifactDaoMockControl.verify();
- projectDaoMockControl.verify();
-
assertActionSuccess( action, result );
assertActionParameters( action );
assertNull( action.getSnapshotVersions() );
}
+ private ProjectVersionReference createReference( String projectId )
+ {
+ ProjectVersionReference reference = new ProjectVersionReference();
+ reference.setNamespace( "groupId" );
+ reference.setProjectId( projectId );
+ reference.setProjectVersion( "version" );
+ reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
+ return reference;
+ }
+
private void assertCoordinate( ArchivaProjectModel dependee, String artifactId )
{
assertEquals( artifactId, dependee.getArtifactId() );
return model;
}
- private ArchivaProjectModel createLegacyProjectModel( String groupId, String artifactId, String version )
- {
- ArchivaProjectModel model = createBasicLegacyModel( groupId, artifactId, version );
- model.setPackaging( TEST_PACKAGING );
- model.setUrl( TEST_URL );
- model.setName( TEST_NAME );
- model.setDescription( TEST_DESCRIPTION );
- VersionedReference parent = new VersionedReference();
- parent.setGroupId( TEST_PARENT_GROUP_ID );
- parent.setArtifactId( TEST_PARENT_ARTIFACT_ID );
- parent.setVersion( TEST_PARENT_VERSION );
- model.setParentProject( parent );
- org.apache.maven.archiva.model.CiManagement ci = new org.apache.maven.archiva.model.CiManagement();
- ci.setSystem( TEST_CI_SYSTEM );
- ci.setUrl( TEST_CI_URL );
- model.setCiManagement( ci );
- org.apache.maven.archiva.model.IssueManagement issue = new org.apache.maven.archiva.model.IssueManagement();
- issue.setSystem( TEST_ISSUE_SYSTEM );
- issue.setUrl( TEST_ISSUE_URL );
- model.setIssueManagement( issue );
- org.apache.maven.archiva.model.Organization org = new org.apache.maven.archiva.model.Organization();
- org.setName( TEST_ORGANIZATION_NAME );
- org.setUrl( TEST_ORGANIZATION_URL );
- model.setOrganization( org );
- org.apache.maven.archiva.model.License l = new org.apache.maven.archiva.model.License();
- l.setName( TEST_LICENSE_NAME );
- l.setUrl( TEST_LICENSE_URL );
- model.addLicense( l );
- l = new org.apache.maven.archiva.model.License();
- l.setName( TEST_LICENSE_NAME_2 );
- l.setUrl( TEST_LICENSE_URL_2 );
- model.addLicense( l );
- org.apache.maven.archiva.model.Scm scm = new org.apache.maven.archiva.model.Scm();
- scm.setConnection( TEST_SCM_CONNECTION );
- scm.setDeveloperConnection( TEST_SCM_DEV_CONNECTION );
- scm.setUrl( TEST_SCM_URL );
- model.setScm( scm );
- return model;
- }
-
- private ArchivaProjectModel createBasicLegacyModel( String groupId, String artifactId, String version )
- {
- ArchivaProjectModel model = new ArchivaProjectModel();
- model.setGroupId( groupId );
- model.setArtifactId( artifactId );
- model.setVersion( version );
- return model;
- }
-
- private MockControl createArtifactDaoMock( List<ArchivaArtifact> artifacts, int count )
- throws ArchivaDatabaseException
- {
- return createArtifactDaoMock( artifacts, TEST_VERSION, count );
- }
-
- private MockControl createArtifactDaoMock( List<ArchivaArtifact> artifacts, String version, int count )
- throws ArchivaDatabaseException
- {
- // testing deeper than normal with the mocks as we intend to replace RepositoryBrowsing, not just the database
- // underneath it - those sections will be adjusted with a mock content repository later
- MockControl control = MockControl.createNiceControl( ArtifactDAO.class );
- ArtifactDAO dao = (ArtifactDAO) control.getMock();
- archivaDao.setArtifactDao( dao );
-
- ArtifactsRelatedConstraint c = new ArtifactsRelatedConstraint( TEST_GROUP_ID, TEST_ARTIFACT_ID, version );
- dao.queryArtifacts( c );
- control.setReturnValue( artifacts, count );
-
- control.replay();
- return control;
- }
-
- private ArchivaArtifact createArtifact( String groupId, String artifactId, String version )
- {
- return createArtifact( groupId, artifactId, version, TEST_REPO );
- }
-
- private ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String repoId )
- {
- ArchivaArtifactModel model = new ArchivaArtifactModel();
- model.setGroupId( groupId );
- model.setArtifactId( artifactId );
- model.setVersion( version );
- model.setRepositoryId( repoId );
- return new ArchivaArtifact( model );
- }
-
protected void setUp()
throws Exception
{
super.setUp();
action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT );
metadataResolver = (TestMetadataResolver) action.getMetadataResolver();
- archivaDao = (ArchivaDAOStub) lookup( ArchivaDAO.class, "jdo" );
}
}
--- /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 class ProjectVersionReference
+{
+ private ReferenceType referenceType;
+
+ private String projectId;
+
+ private String namespace;
+
+ private String projectVersion;
+
+ public void setReferenceType( ReferenceType referenceType )
+ {
+ this.referenceType = referenceType;
+ }
+
+ public void setNamespace( String namespace )
+ {
+ this.namespace = namespace;
+ }
+
+ public void setProjectId( String projectId )
+ {
+ this.projectId = projectId;
+ }
+
+ public ReferenceType getReferenceType()
+ {
+ return referenceType;
+ }
+
+ public String getProjectId()
+ {
+ return projectId;
+ }
+
+ public String getProjectVersion()
+ {
+ return projectVersion;
+ }
+
+ public String getNamespace()
+ {
+ return namespace;
+ }
+
+ public void setProjectVersion( String projectVersion )
+ {
+ this.projectVersion = projectVersion;
+ }
+
+ public enum ReferenceType
+ {
+ DEPENDENCY,
+ PARENT
+ }
+}
import java.util.Collection;
+import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
/**
* @plexus.component role="org.apache.archiva.metadata.repository.MetadataResolver"
/**
* FIXME: this needs to be configurable based on storage type, and availability of proxy module
* ... could be a different type since we need methods to modify the storage metadata, which would also allow more
- * appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
+ * appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
*
* @plexus.requirement role-hint="maven2"
*/
metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion );
if ( metadata != null )
{
+ // FIXME: make this a more generic post-processing that plugins can take advantage of
+ // eg. maven projects should be able to process parent here
+ if ( !metadata.getDependencies().isEmpty() )
+ {
+ ProjectVersionReference ref = new ProjectVersionReference();
+ ref.setNamespace( namespace );
+ ref.setProjectId( projectId );
+ ref.setProjectVersion( projectVersion );
+ ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
+ for ( Dependency dependency : metadata.getDependencies() )
+ {
+ metadataRepository.updateProjectReference( repoId, dependency.getGroupId(),
+ dependency.getArtifactId(), dependency.getVersion(),
+ ref );
+ }
+ }
metadataRepository.updateProjectVersion( repoId, namespace, projectId, metadata );
}
}
// TODO: intercept
return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion );
}
+
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ // TODO: is this assumption correct? could a storage mech. actually know all references in a non-Maven scenario?
+ // not passed to the storage mechanism as resolving references would require iterating all artifacts
+ return metadataRepository.getProjectReferences( repoId, namespace, projectId, projectVersion );
+ }
}
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
public interface MetadataRepository
extends MetadataResolver
void updateProjectVersion( String repoId, String namespace, String projectId,
ProjectVersionMetadata versionMetadata );
+ void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
+ ProjectVersionReference reference );
}
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
public interface MetadataResolver
{
throws MetadataResolverException;
Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion );
+
+ /**
+ * Retrieve project references from the metadata repository. Note that this is not built into the content model for
+ * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual
+ * project is, and we want to avoid adding a stub model to the content repository.
+ *
+ * @param repoId the repository ID to look within
+ * @param namespace the namespace of the project to get references to
+ * @param projectId the identifier of the project to get references to
+ * @param projectVersion the version of the project to get references to
+ * @return a list of project references
+ */
+ Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion );
}
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.MetadataResolverException;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
{
throw new UnsupportedOperationException();
}
+
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ throw new UnsupportedOperationException();
+ }
}
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionFacet;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.model.Scm;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.commons.io.IOUtils;
public void updateProjectVersion( String repoId, String namespace, String projectId,
ProjectVersionMetadata versionMetadata )
{
- File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId );
+ File directory =
+ new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + versionMetadata.getId() );
- Properties properties = new Properties();
+ Properties properties = readProperties( directory );
+ // remove properties that are not references or artifacts
+ for ( String name : properties.stringPropertyNames() )
+ {
+ if ( !name.startsWith( "artifact:" ) && !name.startsWith( "ref:" ) )
+ {
+ properties.remove( name );
+ }
+ }
properties.setProperty( "id", versionMetadata.getId() );
setProperty( properties, "name", versionMetadata.getName() );
setProperty( properties, "description", versionMetadata.getDescription() );
try
{
- writeProperties( properties, new File( directory, versionMetadata.getId() ) );
+ writeProperties( properties, directory );
+ }
+ catch ( IOException e )
+ {
+ // TODO
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+ public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
+ ProjectVersionReference reference )
+ {
+ File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + projectVersion );
+
+ Properties properties = readProperties( directory );
+ int i = Integer.valueOf( properties.getProperty( "ref:lastReferenceNum", "-1" ) ) + 1;
+ setProperty( properties, "ref:lastReferenceNum", Integer.toString( i ) );
+ setProperty( properties, "ref:reference." + i + ".namespace", reference.getNamespace() );
+ setProperty( properties, "ref:reference." + i + ".projectId", reference.getProjectId() );
+ setProperty( properties, "ref:reference." + i + ".projectVersion", reference.getProjectVersion() );
+ setProperty( properties, "ref:reference." + i + ".referenceType", reference.getReferenceType().toString() );
+
+ try
+ {
+ writeProperties( properties, directory );
}
catch ( IOException e )
{
Properties properties = readProperties( directory );
- properties.setProperty( "updated:" + artifact.getId(), Long.toString( artifact.getUpdated().getTime() ) );
- properties.setProperty( "size:" + artifact.getId(), Long.toString( artifact.getSize() ) );
- properties.setProperty( "version:" + artifact.getId(), artifact.getVersion() );
+ properties.setProperty( "artifact:updated:" + artifact.getId(),
+ Long.toString( artifact.getUpdated().getTime() ) );
+ properties.setProperty( "artifact:size:" + artifact.getId(), Long.toString( artifact.getSize() ) );
+ properties.setProperty( "artifact:version:" + artifact.getId(), artifact.getVersion() );
try
{
return versions;
}
+ public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
+ String projectVersion )
+ {
+ File directory = new File( this.directory, repoId + "/" + namespace + "/" + projectId + "/" + projectVersion );
+
+ Properties properties = readProperties( directory );
+ int numberOfRefs = Integer.valueOf( properties.getProperty( "ref:lastReferenceNum", "-1" ) ) + 1;
+
+ List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
+ for ( int i = 0; i < numberOfRefs; i++ )
+ {
+ ProjectVersionReference reference = new ProjectVersionReference();
+ reference.setProjectId( properties.getProperty( "ref:reference." + i + ".projectId" ) );
+ reference.setNamespace( properties.getProperty( "ref:reference." + i + ".namespace" ) );
+ reference.setProjectVersion( properties.getProperty( "ref:reference." + i + ".projectVersion" ) );
+ reference.setReferenceType( ProjectVersionReference.ReferenceType.valueOf(
+ properties.getProperty( "ref:reference." + i + ".referenceType" ) ) );
+ references.add( reference );
+ }
+ return references;
+ }
+
private void writeProperties( Properties properties, File directory )
throws IOException
{