mirror of
https://github.com/apache/archiva.git
synced 2025-02-27 21:19:11 +00:00
add a rest method to get artifact dependees
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a105ea35a5
commit
f61e9b7ba9
@ -129,6 +129,7 @@ public class Artifact
|
||||
|
||||
/**
|
||||
* file extension of the artifact
|
||||
*
|
||||
* @since 1.4-M2
|
||||
*/
|
||||
private String fileExtension;
|
||||
@ -139,6 +140,13 @@ public Artifact()
|
||||
// no op
|
||||
}
|
||||
|
||||
public Artifact( String groupId, String artifactId, String version )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
this.groupId = groupId;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
import org.apache.archiva.rest.api.model.Artifact;
|
||||
import org.apache.archiva.rest.api.model.BrowseResult;
|
||||
import org.apache.archiva.rest.api.model.TreeEntry;
|
||||
import org.apache.archiva.rest.api.model.VersionsList;
|
||||
@ -96,4 +97,12 @@ List<TreeEntry> getTreeEntries( @PathParam( "g" ) String groupId, @PathParam( "a
|
||||
@PathParam( "v" ) String version,
|
||||
@QueryParam( "repositoryId" ) String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "dependees/{g}/{a}/{v}" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noPermission = true, noRestriction = true )
|
||||
List<Artifact> getDependees( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
|
||||
@PathParam( "v" ) String version, @QueryParam( "repositoryId" ) String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
import org.apache.archiva.common.utils.VersionComparator;
|
||||
import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionReference;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolutionException;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolver;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
@ -567,6 +568,43 @@ public List<ManagedRepository> getUserRepositories()
|
||||
}
|
||||
}
|
||||
|
||||
public List<Artifact> getDependees( String groupId, String artifactId, String version, String repositoryId )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
|
||||
// TODO: what if we get duplicates across repositories?
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
MetadataResolver metadataResolver = repositorySession.getResolver();
|
||||
for ( String repoId : getObservableRepos() )
|
||||
{
|
||||
// TODO: what about if we want to see this irrespective of version?
|
||||
references.addAll(
|
||||
metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, artifactId,
|
||||
version ) );
|
||||
}
|
||||
}
|
||||
catch ( MetadataResolutionException e )
|
||||
{
|
||||
throw new ArchivaRestServiceException( e.getMessage(),
|
||||
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
repositorySession.close();
|
||||
}
|
||||
|
||||
List<Artifact> artifacts = new ArrayList<Artifact>( references.size() );
|
||||
|
||||
for ( ProjectVersionReference projectVersionReference : references )
|
||||
{
|
||||
artifacts.add( new Artifact( projectVersionReference.getNamespace(), projectVersionReference.getProjectId(),
|
||||
projectVersionReference.getProjectVersion() ) );
|
||||
}
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
// internals
|
||||
//---------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user